diff --git a/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php b/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php index 475688e..f303f79 100644 --- a/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php @@ -137,23 +137,6 @@ protected function cacheSet($entities) { } /** - * {@inheritdoc} - */ - public function invokeFieldMethod($method, EntityInterface $entity) { - // Only act on content entities. - if (!($entity instanceof ContentEntityInterface)) { - return; - } - - foreach (array_keys($entity->getTranslationLanguages()) as $langcode) { - $translation = $entity->getTranslation($langcode); - foreach ($translation as $field) { - $field->$method(); - } - } - } - - /** * Invokes a hook on behalf of the entity. * * @param string $hook @@ -169,30 +152,4 @@ protected function invokeHook($hook, EntityInterface $entity) { module_invoke_all('entity_' . $hook, $entity, $this->entityType); } - /** - * 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) { - // Only act on content entities. - if (!($entity instanceof ContentEntityInterface)) { - return; - } - $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)); - } - } - } - } diff --git a/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php b/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php index 71d91a4..f16d863 100644 --- a/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php +++ b/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php @@ -303,11 +303,37 @@ public function onFieldItemsPurge(EntityInterface $entity, FieldInstanceInterfac */ public function onFieldPurge(FieldInterface $field) { } + /** + * Checks translation statuses and invoke the related hooks if needed. + * + * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * The entity being saved. + */ + protected function invokeTranslationHooks(ContentEntityInterface $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)); + } + } + } /** - * {@inheritdoc} + * Invokes a method on the Field objects within an entity. + * + * @param string $method + * The method name. + * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * The entity object. */ - public function invokeFieldMethod($method, EntityInterface $entity) { + protected function invokeFieldMethod($method, ContentEntityInterface $entity) { foreach (array_keys($entity->getTranslationLanguages()) as $langcode) { $translation = $entity->getTranslation($langcode); foreach ($translation as $field) { diff --git a/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerInterface.php b/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerInterface.php index 428b563..a52a5ad 100644 --- a/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerInterface.php +++ b/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerInterface.php @@ -122,14 +122,4 @@ public function onFieldItemsPurge(EntityInterface $entity, FieldInstanceInterfac */ public function onFieldPurge(FieldInterface $field); - /** - * Invokes a method on the Field objects within an entity. - * - * @param string $method - * The method name. - * @param \Drupal\Core\Entity\EntityInterface $entity - * The entity object. - */ - public function invokeFieldMethod($method, EntityInterface $entity); - }