You are here

function entity_delete_multiple in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/includes/entity.inc \entity_delete_multiple()

Deletes multiple entities permanently.

$storage_handler = \Drupal::entityManager()
  ->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\EntityManagerInterface::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 270
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);
}