diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php index bb0cf4c..143a2ab 100644 --- a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php +++ b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php @@ -369,7 +369,7 @@ public function save(EntityInterface $entity) { $this->invokeFieldMethod('update', $entity); $this->invokeHook('update', $entity); if ($this->dataTable) { - $this->notifyTranslationChanges($entity); + $this->invokeTranslationHooks($entity); } } else { @@ -490,28 +490,6 @@ protected function savePropertyData(EntityInterface $entity) { } /** - * Checks translation statuses and invoke the related hooks if needed. - * - * @param \Drupal\Core\Entity\EntityInterface $entity - * The entity being saved. - */ - function notifyTranslationChanges(EntityInterface $entity) { - $translations = $entity->getTranslationLanguages(FALSE); - $original_translations = $entity->original->getTranslationLanguages(FALSE); - $all_translations = array_keys($translations + $original_translations); - - // Notify modules of translation insertion/deletion. - foreach ($all_translations as $langcode) { - if (isset($translations[$langcode]) && !isset($original_translations[$langcode])) { - $this->invokeHook('translation_insert', $entity->getTranslation($langcode)); - } - elseif (!isset($translations[$langcode]) && isset($original_translations[$langcode])) { - $this->invokeHook('translation_delete', $entity->getTranslation($langcode)); - } - } - } - - /** * Maps from an entity object to the storage record of the base table. * * @param \Drupal\Core\Entity\EntityInterface $entity diff --git a/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php b/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php index 5dbf55b..b876f2a 100644 --- a/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php @@ -234,4 +234,26 @@ public function invokeFieldItemPrepareCache(EntityInterface $entity) { } } + /** + * Checks translation statuses and invoke the related hooks if needed. + * + * @param \Drupal\Core\Entity\EntityInterface $entity + * The entity being saved. + */ + protected function invokeTranslationHooks(EntityInterface $entity) { + $translations = $entity->getTranslationLanguages(FALSE); + $original_translations = $entity->original->getTranslationLanguages(FALSE); + $all_translations = array_keys($translations + $original_translations); + + // Notify modules of translation insertion/deletion. + foreach ($all_translations as $langcode) { + if (isset($translations[$langcode]) && !isset($original_translations[$langcode])) { + $this->invokeHook('translation_insert', $entity->getTranslation($langcode)); + } + elseif (!isset($translations[$langcode]) && isset($original_translations[$langcode])) { + $this->invokeHook('translation_delete', $entity->getTranslation($langcode)); + } + } + } + }