8.3.x entity.inc entity_delete_multiple($entity_type, array $ids)
8.0.x entity.inc entity_delete_multiple($entity_type, array $ids)
8.1.x entity.inc entity_delete_multiple($entity_type, array $ids)
8.2.x entity.inc entity_delete_multiple($entity_type, array $ids)
8.4.x entity.inc entity_delete_multiple($entity_type, array $ids)

Deletes multiple entities permanently.

$storage_handler = \Drupal::entityTypeManager()->getStorage($entity_type);
$entities = $storage_handler->loadMultiple($ids);
$storage_handler->delete($entities);

Parameters

string $entity_type: The type of the entity.

array $ids: An array of entity IDs of the entities to delete.

Deprecated

as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use the entity storage's delete() method to delete multiple entities:

See also

\Drupal\Core\Entity\EntityTypeManagerInterface::getStorage()

\Drupal\Core\Entity\EntityStorageInterface::loadMultiple()

\Drupal\Core\Entity\EntityStorageInterface::delete()

21 calls to entity_delete_multiple()
BlockTest::testBlockCacheTags in core/modules/block/src/Tests/BlockTest.php
Test that cache tags are properly set and bubbled up to the page cache.
BookTest::testBookDelete in core/modules/book/src/Tests/BookTest.php
Tests the access for deleting top-level book nodes.
Comment::postDelete in core/modules/comment/src/Entity/Comment.php
Acts on deleted entities before the delete hook is invoked.
CommentLinksTest::testCommentLinks in core/modules/comment/src/Tests/CommentLinksTest.php
Tests that comment links are output and can be hidden.
CommentNodeChangesTest::testNodeDeletion in core/modules/comment/src/Tests/CommentNodeChangesTest.php
Tests that comments are deleted with the node.

... See full list

File

core/includes/entity.inc, line 278
Entity API for handling entities like nodes or users.

Code

function entity_delete_multiple($entity_type, array $ids) {
  $controller = \Drupal::entityManager()->getStorage($entity_type);
  $entities = $controller->loadMultiple($ids);
  $controller->delete($entities);
}