W3cubDocs

/Drupal 8

function entity_delete_multiple

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()

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);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!includes!entity.inc/function/entity_delete_multiple/8.1.x