hook_ENTITY_TYPE_delete

hook_ENTITY_TYPE_delete(Drupal\Core\Entity\EntityInterface $entity)

Respond to entity deletion of a particular type.

This hook runs once the entity has been deleted from the storage.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity object for the entity that has been deleted.

See also

hook_entity_delete()

Related topics

Entity CRUD, editing, and view hooks
Hooks used in various entity operations.
Hooks
Define functions that alter the behavior of Drupal core.

File

core/lib/Drupal/Core/Entity/entity.api.php, line 1220
Hooks and documentation related to entities.

Code

function hook_ENTITY_TYPE_delete(Drupal\Core\Entity\EntityInterface $entity) {
  // Delete the entity's entry from a fictional table of all entities.
  db_delete('example_entity')
    ->condition('type', $entity->getEntityTypeId())
    ->condition('id', $entity->id())
    ->execute();
}
doc_Drupal
2016-10-29 09:18:04
Comments
Leave a Comment

Please login to continue.