function hook_entity_update
Same name and namespace in other branches
- 7.x modules/system/system.api.php \hook_entity_update()
- 9 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_update()
- 8.9.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_update()
- 10 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_update()
Respond to updates to an entity.
This hook runs once the entity storage has been updated. Note that hook implementations may not alter the stored entity data. Get the original entity object from $entity->getOriginal().
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity object.
See also
Related topics
1 string reference to 'hook_entity_update'
- WorkspacesTestHooks::entityUpdate in core/
modules/ workspaces/ tests/ modules/ workspaces_test/ src/ Hook/ WorkspacesTestHooks.php - Implements hook_entity_update().
9 functions implement hook_entity_update()
Note: the procedural functions in this list are found by pattern matching, so the list may include some functions that are not actually implementations of this hook.
- ContentModerationHooks::entityUpdate in core/
modules/ content_moderation/ src/ Hook/ ContentModerationHooks.php - Implements hook_entity_update().
- EditorHooks::entityUpdate in core/
modules/ editor/ src/ Hook/ EditorHooks.php - Implements hook_entity_update().
- EditorTestHooks::entityUpdate in core/
modules/ editor/ tests/ modules/ editor_test/ src/ Hook/ EditorTestHooks.php - Implements hook_entity_update().
- editor_test_entity_update in core/
modules/ editor/ tests/ modules/ editor_test/ editor_test.module - Implements hook_entity_update().
- EntityCrudHookTestHooks::entityUpdate in core/
modules/ system/ tests/ modules/ entity_crud_hook_test/ src/ Hook/ EntityCrudHookTestHooks.php - Implements hook_entity_update().
File
-
core/
lib/ Drupal/ Core/ Entity/ entity.api.php, line 1254
Code
function hook_entity_update(\Drupal\Core\Entity\EntityInterface $entity) : void {
// Update the entity's entry in a fictional table of all entities.
\Drupal::database()->update('example_entity')
->fields([
'updated' => \Drupal::time()->getRequestTime(),
])
->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.