function hook_entity_presave

Act on an entity before it is about to be created or updated.

Parameters

Drupal\Core\Entity\EntityInterface $entity: The entity object.

Related topics

3 functions implement hook_entity_presave()

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_presave in drupal/core/modules/system/tests/modules/entity_crud_hook_test/entity_crud_hook_test.module
Implements hook_entity_presave().
entity_test_entity_presave in drupal/core/modules/system/tests/modules/entity_test/entity_test.module
Implements hook_entity_presave()
image_entity_presave in drupal/core/modules/image/image.module
Implements hook_entity_presave().
4 invocations of hook_entity_presave()
ConfigStorageController::save in drupal/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
Implements Drupal\Core\Entity\EntityStorageControllerInterface::save().
DatabaseStorageController::save in drupal/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
Implements \Drupal\Core\Entity\EntityStorageControllerInterface::save().
DatabaseStorageControllerNG::save in drupal/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php
Overrides DatabaseStorageController::save().
MenuLinkStorageController::save in drupal/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php
Overrides DatabaseStorageController::save().

File

drupal/core/includes/entity.api.php, line 204
Hooks provided the Entity module.

Code

function hook_entity_presave(Drupal\Core\Entity\EntityInterface $entity) {
  $entity->changed = REQUEST_TIME;
}