function LoginLogoutMenuLink::getRouteName

Same name and namespace in other branches
  1. 9 core/modules/user/src/Plugin/Menu/LoginLogoutMenuLink.php \Drupal\user\Plugin\Menu\LoginLogoutMenuLink::getRouteName()
  2. 8.9.x core/modules/user/src/Plugin/Menu/LoginLogoutMenuLink.php \Drupal\user\Plugin\Menu\LoginLogoutMenuLink::getRouteName()
  3. 10 core/modules/user/src/Plugin/Menu/LoginLogoutMenuLink.php \Drupal\user\Plugin\Menu\LoginLogoutMenuLink::getRouteName()

Overrides MenuLinkBase::getRouteName

File

core/modules/user/src/Plugin/Menu/LoginLogoutMenuLink.php, line 70

Class

LoginLogoutMenuLink
A menu link that shows "Log in" or "Log out" as appropriate.

Namespace

Drupal\user\Plugin\Menu

Code

public function getRouteName() {
    if ($this->currentUser
        ->isAuthenticated()) {
        return 'user.logout';
    }
    else {
        return 'user.login';
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.