You are here

function hook_ENTITY_TYPE_delete in Entity API 7

Act on entities when deleted.

Parameters

$entity: The entity object.

See also

hook_entity_delete()

4 functions implement hook_ENTITY_TYPE_delete()

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

entity_revision_delete in ./entity.module
Deletes an entity revision.
entity_test_entity_delete in tests/entity_test.module
Implements hook_entity_delete().
entity_test_entity_test_type_delete in tests/entity_test.module
Implements hook_entity_test_type_delete().
entity_test_i18n_entity_test_type_delete in tests/entity_test_i18n.module
Implements hook_{entity_test_type}_delete().

File

./entity.api.php, line 545
Hooks provided by the entity API.

Code

function hook_ENTITY_TYPE_delete($entity) {

  // 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();
}