function hook_entity_update

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_update()
  2. 8.9.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_update()
  3. 10 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_update()
  4. 11.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_update()

Act on entities when updated.

Parameters

$entity: The entity object.

$type: The type of entity being updated (i.e. node, user, comment).

Related topics

1 function implements hook_entity_update()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

entity_crud_hook_test_entity_update in modules/simpletest/tests/entity_crud_hook_test.module
Implements hook_entity_update().
4 invocations of hook_entity_update()
comment_save in modules/comment/comment.module
Accepts a submission of new or changed comment content.
file_save in includes/file.inc
Saves a file object to the database.
taxonomy_vocabulary_save in modules/taxonomy/taxonomy.module
Saves a vocabulary.
user_save in modules/user/user.module
Save changes to a user account or add a new user.

File

modules/system/system.api.php, line 350

Code

function hook_entity_update($entity, $type) {
    // Update the entity's entry in a fictional table of all entities.
    $info = entity_get_info($type);
    list($id) = entity_extract_ids($type, $entity);
    db_update('example_entity')->fields(array(
        'updated' => REQUEST_TIME,
    ))
        ->condition('type', $type)
        ->condition('id', $id)
        ->execute();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.