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);
}
doc_Drupal
2016-10-29 09:09:14
Comments
Leave a Comment

Please login to continue.