Implements Drupal\Core\Entity\EntityStorageControllerInterface::delete().
Overrides EntityStorageControllerInterface::delete
public function delete(array $entities) {
if (!$entities) {
// If no IDs or invalid IDs were passed, do nothing.
return;
}
$transaction = db_transaction();
try {
$this
->preDelete($entities);
foreach ($entities as $id => $entity) {
$this
->invokeHook('predelete', $entity);
}
$ids = array_keys($entities);
db_delete($this->entityInfo['base_table'])
->condition($this->idKey, $ids, 'IN')
->execute();
if ($this->revisionKey) {
db_delete($this->revisionTable)
->condition($this->idKey, $ids, 'IN')
->execute();
}
// Reset the cache as soon as the changes have been applied.
$this
->resetCache($ids);
$this
->postDelete($entities);
foreach ($entities as $id => $entity) {
$this
->invokeHook('delete', $entity);
}
// Ignore slave server temporarily.
db_ignore_slave();
} catch (Exception $e) {
$transaction
->rollback();
watchdog_exception($this->entityType, $e);
throw new EntityStorageException($e->getMessage, $e->getCode, $e);
}
}