function hook_entity_presave
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_presave()
- 8.9.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_presave()
- 10 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_presave()
- 11.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_presave()
Act on an entity before it is about to be created or updated.
Parameters
$entity: The entity object.
$type: The type of entity being saved (i.e. node, user, comment).
Related topics
10 functions implement hook_entity_presave()
Note: the procedural functions in this list are found by pattern matching, so the list may include some functions that are not actually implementations of this hook.
- ContentModerationHooks::entityPresave in core/
modules/ content_moderation/ src/ Hook/ ContentModerationHooks.php - Implements hook_entity_presave().
- ContentTranslationHooks::entityPresave in core/
modules/ content_translation/ src/ Hook/ ContentTranslationHooks.php - Implements hook_entity_presave().
- EntityCrudHookTestHooks::entityPresave in core/
modules/ system/ tests/ modules/ entity_crud_hook_test/ src/ Hook/ EntityCrudHookTestHooks.php - Implements hook_entity_presave().
- EntityOperations::entityPresave in core/
modules/ workspaces/ src/ Hook/ EntityOperations.php - Implements hook_entity_presave().
- EntityTestHooks::entityPresave in core/
modules/ system/ tests/ modules/ entity_test/ src/ Hook/ EntityTestHooks.php - Implements hook_entity_presave().
6 invocations of hook_entity_presave()
- 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.
- node_save in modules/
node/ node.module - Saves changes to a node or adds a new node.
- taxonomy_term_save in modules/
taxonomy/ taxonomy.module - Saves a term object to the database.
- taxonomy_vocabulary_save in modules/
taxonomy/ taxonomy.module - Saves a vocabulary.
File
-
modules/
system/ system.api.php, line 316
Code
function hook_entity_presave($entity, $type) {
$entity->changed = REQUEST_TIME;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.