diff --git a/src/TwigExtension.php b/src/TwigExtension.php index 136d063..c756402 100644 --- a/src/TwigExtension.php +++ b/src/TwigExtension.php @@ -622,10 +622,9 @@ class TwigExtension extends \Twig_Extension { } if ($entity) { + $entity = \Drupal::service('entity.repository')->getTranslationFromContext($entity, $langcode); $access = $check_access ? $entity->access('view', NULL, TRUE) : AccessResult::allowed(); if ($access->isAllowed()) { - $entity = \Drupal::service('entity.repository') - ->getTranslationFromContext($entity, $langcode); if (isset($entity->{$field_name})) { $build = $entity->{$field_name}->view($view_mode); CacheableMetadata::createFromRenderArray($build)