Browse Source

Issue #2994996 by aangel: Field access check should test using language

merge-requests/4/head
Chi 5 years ago
parent
commit
84c486c2ed
  1. 3
      src/TwigExtension.php

3
src/TwigExtension.php

@ -622,10 +622,9 @@ class TwigExtension extends \Twig_Extension {
} }
if ($entity) { if ($entity) {
$entity = \Drupal::service('entity.repository')->getTranslationFromContext($entity, $langcode);
$access = $check_access ? $entity->access('view', NULL, TRUE) : AccessResult::allowed(); $access = $check_access ? $entity->access('view', NULL, TRUE) : AccessResult::allowed();
if ($access->isAllowed()) { if ($access->isAllowed()) {
$entity = \Drupal::service('entity.repository')
->getTranslationFromContext($entity, $langcode);
if (isset($entity->{$field_name})) { if (isset($entity->{$field_name})) {
$build = $entity->{$field_name}->view($view_mode); $build = $entity->{$field_name}->view($view_mode);
CacheableMetadata::createFromRenderArray($build) CacheableMetadata::createFromRenderArray($build)

Loading…
Cancel
Save