You are here

public function RoleAccessCheck::access in Examples for Developers 3.x

Same name and namespace in other branches
  1. 8 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

modules/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());
}