1 entity.api.php | hook_entity_update($entity, $type) |
Act on entities when updated.
Parameters
$entity: The entity object.
$type: The type of entity being updated (e.g. node, user, comment).
Related topics
File
- core/
modules/ entity/ entity.api.php, line 268 - Hooks provided by the Entity module.
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();
}