|
|
@ -4,6 +4,7 @@ namespace Drupal\twig_tweak; |
|
|
|
|
|
|
|
|
|
|
|
use Drupal\Component\Uuid\Uuid; |
|
|
|
use Drupal\Component\Uuid\Uuid; |
|
|
|
use Drupal\Core\Block\TitleBlockPluginInterface; |
|
|
|
use Drupal\Core\Block\TitleBlockPluginInterface; |
|
|
|
|
|
|
|
use Drupal\Core\Language\LanguageInterface; |
|
|
|
use Drupal\Core\Link; |
|
|
|
use Drupal\Core\Link; |
|
|
|
use Drupal\Core\Site\Settings; |
|
|
|
use Drupal\Core\Site\Settings; |
|
|
|
use Drupal\Core\Url; |
|
|
|
use Drupal\Core\Url; |
|
|
@ -188,9 +189,8 @@ class TwigExtension extends \Twig_Extension { |
|
|
|
? \Drupal::entityTypeManager()->getStorage($entity_type)->load($id) |
|
|
|
? \Drupal::entityTypeManager()->getStorage($entity_type)->load($id) |
|
|
|
: \Drupal::routeMatch()->getParameter($entity_type); |
|
|
|
: \Drupal::routeMatch()->getParameter($entity_type); |
|
|
|
if ($entity && (!$check_access || $entity->access('view'))) { |
|
|
|
if ($entity && (!$check_access || $entity->access('view'))) { |
|
|
|
if ($langcode && $entity->hasTranslation($langcode)) { |
|
|
|
$entity = \Drupal::service('entity.repository') |
|
|
|
$entity = $entity->getTranslation($langcode); |
|
|
|
->getTranslationFromContext($entity, $langcode); |
|
|
|
} |
|
|
|
|
|
|
|
if (isset($entity->{$field_name})) { |
|
|
|
if (isset($entity->{$field_name})) { |
|
|
|
return $entity->{$field_name}->view($view_mode); |
|
|
|
return $entity->{$field_name}->view($view_mode); |
|
|
|
} |
|
|
|
} |
|
|
|