currentUser = $current_user; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { return new static( $configuration, $plugin_id, $plugin_definition, $container->get('menu_link.static.overrides'), $container->get('current_user') ); } /** * {@inheritdoc} */ public function getTitle() { if ($this->currentUser->isAuthenticated()) { return $this->t('Log out'); } else { return $this->t('Log in'); } } /** * {@inheritdoc} */ public function getRouteName() { if ($this->currentUser->isAuthenticated()) { return 'user.logout'; } else { return 'user.login'; } } /** * {@inheritdoc} */ public function getCacheContexts() { return ['user.roles:authenticated']; } }