function entity_delete_multiple

Deletes multiple entities permanently.

Parameters

string $entity_type: The type of the entity.

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

Deprecated

in drupal:8.0.0 and is removed from drupal:9.0.0. Use the entity storage's \Drupal\Core\Entity\EntityStorageInterface::delete() method to delete multiple entities:

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

See also

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

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

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

https://www.drupal.org/node/3051072

2 calls to entity_delete_multiple()
EntityLegacyTest::testEntityDeleteMultiple in core/tests/Drupal/KernelTests/Core/Entity/EntityLegacyTest.php
Tests that entity_delete_multiple triggers an error.
user_delete_multiple in core/modules/user/user.module
Delete multiple user accounts.

File

core/includes/entity.inc, line 249

Code

function entity_delete_multiple($entity_type, array $ids) {
    @trigger_error(__FUNCTION__ . ' is deprecated in drupal:8.0.0 and will be removed in drupal:9.0.0. Use the entity storage\'s delete() method to delete multiple entities. @see https://www.drupal.org/node/3051072', E_USER_DEPRECATED);
    $controller = \Drupal::entityManager()->getStorage($entity_type);
    $entities = $controller->loadMultiple($ids);
    $controller->delete($entities);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.