From 3dd5b1f13255b9da9f605977d9e1c4914fa77a84 Mon Sep 17 00:00:00 2001 From: xjm Date: Sun, 22 Nov 2015 14:00:50 -0600 Subject: [PATCH] Issue #2620764 by andypost: Fix entity.api hook_entity_translation_* examples --- core/lib/Drupal/Core/Entity/entity.api.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/core/lib/Drupal/Core/Entity/entity.api.php b/core/lib/Drupal/Core/Entity/entity.api.php index 9cfa22980f4b..686271d5f173 100644 --- a/core/lib/Drupal/Core/Entity/entity.api.php +++ b/core/lib/Drupal/Core/Entity/entity.api.php @@ -1051,7 +1051,7 @@ function hook_ENTITY_TYPE_translation_create(\Drupal\Core\Entity\EntityInterface */ function hook_entity_translation_insert(\Drupal\Core\Entity\EntityInterface $translation) { $variables = array( - '@language' => $translation->language()->name, + '@language' => $translation->language()->getName(), '@label' => $translation->getUntranslated()->label(), ); \Drupal::logger('example')->notice('The @language translation of @label has just been stored.', $variables); @@ -1071,7 +1071,7 @@ function hook_entity_translation_insert(\Drupal\Core\Entity\EntityInterface $tra */ function hook_ENTITY_TYPE_translation_insert(\Drupal\Core\Entity\EntityInterface $translation) { $variables = array( - '@language' => $translation->language()->name, + '@language' => $translation->language()->getName(), '@label' => $translation->getUntranslated()->label(), ); \Drupal::logger('example')->notice('The @language translation of @label has just been stored.', $variables); @@ -1089,10 +1089,9 @@ function hook_ENTITY_TYPE_translation_insert(\Drupal\Core\Entity\EntityInterface * @see hook_ENTITY_TYPE_translation_delete() */ function hook_entity_translation_delete(\Drupal\Core\Entity\EntityInterface $translation) { - $languages = \Drupal::languageManager()->getLanguages(); $variables = array( - '@language' => $languages[$langcode]->name, - '@label' => $entity->label(), + '@language' => $translation->language()->getName(), + '@label' => $translation->label(), ); \Drupal::logger('example')->notice('The @language translation of @label has just been deleted.', $variables); } @@ -1109,10 +1108,9 @@ function hook_entity_translation_delete(\Drupal\Core\Entity\EntityInterface $tra * @see hook_entity_translation_delete() */ function hook_ENTITY_TYPE_translation_delete(\Drupal\Core\Entity\EntityInterface $translation) { - $languages = \Drupal::languageManager()->getLanguages(); $variables = array( - '@language' => $languages[$langcode]->name, - '@label' => $entity->label(), + '@language' => $translation->language()->getName(), + '@label' => $translation->label(), ); \Drupal::logger('example')->notice('The @language translation of @label has just been deleted.', $variables); }