Same name and namespace in other branches
  1. 10 core/lib/Drupal/Core/Entity/entity.api.php \hook_ENTITY_TYPE_update()
  2. 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

hook_entity_update()

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().
block_post_update_disabled_region_update in core/modules/block/block.post_update.php
Disable blocks that are placed into the "disabled" region.
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.

... See full list

File

core/lib/Drupal/Core/Entity/entity.api.php, line 1209
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();
}