function hook_ENTITY_TYPE_update in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/entity.api.php \hook_ENTITY_TYPE_update()
- 9 core/lib/Drupal/Core/Entity/entity.api.php \hook_ENTITY_TYPE_update()
Respond to updates to an entity of a particular type.
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->original.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity object.
See also
Related topics
46 functions implement hook_ENTITY_TYPE_update()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- block_content_test_block_content_update in core/
modules/ block_content/ tests/ modules/ block_content_test/ block_content_test.module - Implements hook_block_content_update().
- book_form_update in core/
modules/ book/ book.module - Renders a new parent page select element when the book selection changes.
- book_node_type_update in core/
modules/ book/ book.module - Implements hook_ENTITY_TYPE_update() for node_type entities.
- book_node_update in core/
modules/ book/ book.module - Implements hook_ENTITY_TYPE_update() for node entities.
- comment_field_config_update in core/
modules/ comment/ comment.module - Implements hook_ENTITY_TYPE_update() for 'field_config'.
File
- core/
lib/ Drupal/ Core/ Entity/ entity.api.php, line 1218 - Hooks and documentation related to entities.
Code
function hook_ENTITY_TYPE_update(\Drupal\Core\Entity\EntityInterface $entity) {
// Update the entity's entry in a fictional table of this type of entity.
\Drupal::database()
->update('example_entity')
->fields([
'updated' => REQUEST_TIME,
])
->condition('id', $entity
->id())
->execute();
}