You are here

public function RoleAccessCheck::access in Examples for Developers 8

Same name and namespace in other branches
  1. 3.x modules/menu_example/src/Access/RoleAccessCheck.php \Drupal\menu_example\Access\RoleAccessCheck::access()

Checks access.

Parameters

\Drupal\Core\Session\AccountInterface $account: The currently logged in account.

Return value

string A \Drupal\Core\Access\AccessInterface constant value.

File

menu_example/src/Access/RoleAccessCheck.php, line 34

Class

RoleAccessCheck
Determines access to routes based on roles.

Namespace

Drupal\menu_example\Access

Code

public function access(AccountInterface $account) {

  // If the user is authenticated, return TRUE.
  return AccessResult::allowedIf($account
    ->isAuthenticated());
}