Issue #2620764 by andypost: Fix entity.api hook_entity_translation_* examples

8.1.x
xjm 2015-11-22 14:00:50 -06:00
parent a9a513691e
commit 3dd5b1f132
1 changed files with 6 additions and 8 deletions

View File

@ -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);
}