function hook_entity_presave in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_presave()
Act on an entity before it is created or updated.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity object.
See also
Related topics
4 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.
- content_translation_entity_presave in core/
modules/ content_translation/ content_translation.module - Implements hook_entity_presave().
- entity_crud_hook_test_entity_presave in core/
modules/ system/ tests/ modules/ entity_crud_hook_test/ entity_crud_hook_test.module - Implements hook_entity_presave().
- entity_test_entity_presave in core/
modules/ system/ tests/ modules/ entity_test/ entity_test.module - Implements hook_entity_presave().
- image_entity_presave in core/
modules/ image/ image.module - Implements hook_entity_presave().
1 invocation of hook_entity_presave()
- EntityStorageBase::doPreSave in core/
lib/ Drupal/ Core/ Entity/ EntityStorageBase.php - Performs presave entity processing.
File
- core/
lib/ Drupal/ Core/ Entity/ entity.api.php, line 893 - Hooks and documentation related to entities.
Code
function hook_entity_presave(Drupal\Core\Entity\EntityInterface $entity) {
if ($entity instanceof ContentEntityInterface && $entity
->isTranslatable()) {
$route_match = \Drupal::routeMatch();
\Drupal::service('content_translation.synchronizer')
->synchronizeFields($entity, $entity
->language()
->getId(), $route_match
->getParameter('source_langcode'));
}
}