currentUser = $current_user; $this->entityRepository = $entity_repository; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( $container->get('entity_type.manager'), $container->get('renderer'), $container->get('current_user'), $container->get('entity.repository') ); } /** * {@inheritdoc} */ public function view(EntityInterface $node, $view_mode = 'full', $langcode = NULL) { return parent::view($node, $view_mode); } /** * The _title_callback for the page that renders a single node. * * @param \Drupal\Core\Entity\EntityInterface $node * The current node. * * @return string * The page title. */ public function title(EntityInterface $node) { return $this->entityRepository->getTranslationFromContext($node)->label(); } }