1 entity.api.php | hook_entity_delete($entity, $type) |
Respond to entity deletion.
This hook runs after the entity type-specific delete hook.
Parameters
$entity: The entity object for the entity that has been deleted.
$type: The type of entity being deleted (i.e. node, user, comment).
Related topics
File
- core/
modules/ entity/ entity.api.php, line 321 - Hooks provided by the Entity module.
Code
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();
}