hook_entity_delete

  1. drupal
    1. 8 entity.api.php
    2. 7
Versions
7 – 8 hook_entity_delete($entity, $type)

Act on entities when deleted.

Parameters

$entity The entity object.

$type The type of entity being deleted (i.e. node, user, comment).

Related topics

Code

modules/system/system.api.php, line 350

<?php
function hook_entity_delete($entity, $type) {
  // Delete the entity's entry from a fictional table of all entities.
  $info = entity_get_info($type);
  list($id) = entity_extract_ids($type, $entity);
  db_delete('example_entity')
    ->condition('type', $type)
    ->condition('id', $id)
    ->execute();
}
?>