hook_ENTITY_TYPE_presave(Drupal\Core\Entity\EntityInterface $entity)
Act on a specific type of entity before it is created or updated.
You can get the original entity object from $entity->original when it is an update of the entity.
\Drupal\Core\Entity\EntityInterface $entity: The entity object.
function hook_ENTITY_TYPE_presave(Drupal\Core\Entity\EntityInterface $entity) { if ($entity->isTranslatable()) { $route_match = \Drupal::routeMatch(); \Drupal::service('content_translation.synchronizer')->synchronizeFields($entity, $entity->language()->getId(), $route_match->getParameter('source_langcode')); } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!entity.api.php/function/hook_ENTITY_TYPE_presave/8.1.x