| 7 system.api.php | hook_entity_update($entity, $type) |
| 8 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 (i.e. node, user, comment).
Related topics
1 function implements hook_entity_update()
4 invocations of hook_entity_update()
File
- modules/
system/ system.api.php, line 329 - Hooks provided by Drupal core and the System 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();
}
Login or register to post comments
Comments
How to access new version of contents?
Much as described in the comments on hook_node_update, I am getting OLD versions of the page contents in code that is run via hook_entity_update.
Unfortunately, the fix suggested in the hook_node_update thread viz.,
entity_get_controller('node')->resetCache(array($node->nid));does not seem to have any useful effect for me.
More specifically: I want to retrieve the new XHTML and do something with it after the user presses save. But so far, no luck. If I view the page's source manually, it's all good - but if I run cURL inside this hook, I just get the OLD contents, which is not useful for me. Should I be using a different hook?