Same name and namespace in other branches
- 8.9.x core/lib/Drupal/Core/Entity/entity.api.php \hook_ENTITY_TYPE_delete()
- 9 core/lib/Drupal/Core/Entity/entity.api.php \hook_ENTITY_TYPE_delete()
Respond to entity deletion of a particular type.
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
Related topics
56 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.
- block_configurable_language_delete in core/
modules/ block/ block.module - Implements hook_ENTITY_TYPE_delete() for 'configurable_language'.
- block_menu_delete in core/
modules/ block/ block.module - Implements hook_ENTITY_TYPE_delete() for menu entities.
- block_user_role_delete in core/
modules/ block/ block.module - Implements hook_ENTITY_TYPE_delete() for user_role entities.
- comment_field_config_delete in core/
modules/ comment/ comment.module - Implements hook_ENTITY_TYPE_delete() for 'field_config'.
- config_test_config_test_delete in core/
modules/ config/ tests/ config_test/ config_test.hooks.inc - Implements hook_config_test_delete().
File
- core/
lib/ Drupal/ Core/ Entity/ entity.api.php, line 1453 - Hooks and documentation related to entities.
Code
function hook_ENTITY_TYPE_delete(\Drupal\Core\Entity\EntityInterface $entity) {
// Delete the entity's entry from a fictional table of all entities.
\Drupal::database()
->delete('example_entity')
->condition('type', $entity
->getEntityTypeId())
->condition('id', $entity
->id())
->execute();
}