You are here

function hook_entity_delete in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_delete()

Respond to entity deletion.

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_TYPE_delete()

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.

editor_entity_delete in core/modules/editor/editor.module
Implements hook_entity_delete().
entity_crud_hook_test_entity_delete in core/modules/system/tests/modules/entity_crud_hook_test/entity_crud_hook_test.module
Implements hook_entity_delete().
1 invocation of hook_entity_delete()
EntityStorageBase::delete in core/lib/Drupal/Core/Entity/EntityStorageBase.php
Deletes permanently saved entities.

File

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

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