function RegisterAccessCheck::access

Same name in other branches
  1. 8.9.x core/modules/user/src/Access/RegisterAccessCheck.php \Drupal\user\Access\RegisterAccessCheck::access()
  2. 10 core/modules/user/src/Access/RegisterAccessCheck.php \Drupal\user\Access\RegisterAccessCheck::access()
  3. 11.x 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);
}

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