You are here

public function RegisterAccessCheck::access in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/user/src/Access/RegisterAccessCheck.php \Drupal\user\Access\RegisterAccessCheck::access()

Checks access.

Parameters

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

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

File

core/modules/user/src/Access/RegisterAccessCheck.php, line 24

Class

RegisterAccessCheck
Access check for user registration routes.

Namespace

Drupal\user\Access

Code

public function access(AccountInterface $account) {
  $user_settings = \Drupal::config('user.settings');
  return AccessResult::allowedIf($account
    ->isAnonymous() && $user_settings
    ->get('register') != UserInterface::REGISTER_ADMINISTRATORS_ONLY)
    ->addCacheableDependency($user_settings);
}