function hook_entity_delete

Respond to entity deletion.

This hook runs after the entity type-specific delete hook.

Parameters

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

Related topics

2 functions implement hook_entity_delete()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

entity_crud_hook_test_entity_delete in drupal/core/modules/system/tests/modules/entity_crud_hook_test/entity_crud_hook_test.module
Implements hook_entity_delete().
translation_entity_entity_delete in drupal/core/modules/translation_entity/translation_entity.module
Implements hook_entity_delete().

File

drupal/core/includes/entity.api.php, line 280
Hooks provided the Entity module.

Code

function hook_entity_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
    ->entityType())
    ->condition('id', $entity
    ->id())
    ->execute();
}