function hook_ENTITY_TYPE_delete
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Entity/entity.api.php \hook_ENTITY_TYPE_delete()
- 10 core/lib/Drupal/Core/Entity/entity.api.php \hook_ENTITY_TYPE_delete()
- 11.x 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
16 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.
- content_moderation_entity_bundle_delete in core/
modules/ content_moderation/ content_moderation.module - Implements hook_entity_bundle_delete().
- content_moderation_entity_revision_delete in core/
modules/ content_moderation/ content_moderation.module - Implements hook_entity_revision_delete().
- content_moderation_entity_translation_delete in core/
modules/ content_moderation/ content_moderation.module - Implements hook_entity_translation_delete().
- editor_entity_revision_delete in core/
modules/ editor/ editor.module - Implements hook_entity_revision_delete().
- entity_schema_test_entity_bundle_delete in core/
modules/ system/ tests/ modules/ entity_schema_test/ entity_schema_test.module - Implements hook_entity_bundle_delete().
File
-
core/
lib/ Drupal/ Core/ Entity/ entity.api.php, line 1460
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();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.