function EntityStorageBase::delete
Same name in other branches
- 9 core/lib/Drupal/Core/Entity/EntityStorageBase.php \Drupal\Core\Entity\EntityStorageBase::delete()
- 8.9.x core/lib/Drupal/Core/Entity/EntityStorageBase.php \Drupal\Core\Entity\EntityStorageBase::delete()
- 11.x core/lib/Drupal/Core/Entity/EntityStorageBase.php \Drupal\Core\Entity\EntityStorageBase::delete()
Overrides EntityStorageInterface::delete
1 call to EntityStorageBase::delete()
- SqlContentEntityStorage::delete in core/
lib/ Drupal/ Core/ Entity/ Sql/ SqlContentEntityStorage.php - Deletes permanently saved entities.
2 methods override EntityStorageBase::delete()
- ContentEntityNullStorage::delete in core/
lib/ Drupal/ Core/ Entity/ ContentEntityNullStorage.php - Deletes permanently saved entities.
- SqlContentEntityStorage::delete in core/
lib/ Drupal/ Core/ Entity/ Sql/ SqlContentEntityStorage.php - Deletes permanently saved entities.
File
-
core/
lib/ Drupal/ Core/ Entity/ EntityStorageBase.php, line 440
Class
- EntityStorageBase
- A base entity storage class.
Namespace
Drupal\Core\EntityCode
public function delete(array $entities) {
if (!$entities) {
// If no entities were passed, do nothing.
return;
}
$entities_by_class = $this->getEntitiesByClass($entities);
// Allow code to run before deleting.
foreach ($entities_by_class as $entity_class => &$items) {
$entity_class::preDelete($this, $items);
foreach ($items as $entity) {
$this->invokeHook('predelete', $entity);
}
// Perform the delete and reset the static cache for the deleted entities.
$this->doDelete($items);
$this->resetCache(array_keys($items));
// Allow code to run after deleting.
$entity_class::postDelete($this, $items);
foreach ($items as $entity) {
$this->invokeHook('delete', $entity);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.