diff --git a/modules/oe_theme_content_organisation/src/Plugin/ExtraField/Display/TeaserDetailsExtraField.php b/modules/oe_theme_content_organisation/src/Plugin/ExtraField/Display/TeaserDetailsExtraField.php index ee05d00b7..771c3f748 100644 --- a/modules/oe_theme_content_organisation/src/Plugin/ExtraField/Display/TeaserDetailsExtraField.php +++ b/modules/oe_theme_content_organisation/src/Plugin/ExtraField/Display/TeaserDetailsExtraField.php @@ -6,6 +6,7 @@ use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\EntityRepositoryInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\extra_field\Plugin\ExtraFieldDisplayFormattedBase; @@ -32,6 +33,13 @@ class TeaserDetailsExtraField extends ExtraFieldDisplayFormattedBase implements */ protected $entityTypeManager; + /** + * The entity repository. + * + * @var \Drupal\Core\Entity\EntityRepositoryInterface + */ + protected $entityRepository; + /** * TeaserDetailsExtraField constructor. * @@ -43,10 +51,13 @@ class TeaserDetailsExtraField extends ExtraFieldDisplayFormattedBase implements * The plugin implementation definition. * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager. + * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository + * The entity repository service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityRepositoryInterface $entity_repository) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->entityTypeManager = $entity_type_manager; + $this->entityRepository = $entity_repository; } /** @@ -57,7 +68,8 @@ public static function create(ContainerInterface $container, array $configuratio $configuration, $plugin_id, $plugin_definition, - $container->get('entity_type.manager') + $container->get('entity_type.manager'), + $container->get('entity.repository') ); } @@ -78,6 +90,7 @@ public function viewElements(ContentEntityInterface $entity) { if (!$contact) { continue; } + $contact = $this->entityRepository->getTranslationFromContext($contact); $contact_access = $contact->access('view', NULL, TRUE); $cache->addCacheableDependency($contact); $cache->addCacheableDependency($contact_access);