You are here

public function RegistrationLinkAccessCheck::access in Registration Link 8.2

Checks access.

Parameters

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

Return value

$this|\Drupal\Core\Access\AccessResultAllowed The access result.

File

src/Access/RegistrationLinkAccessCheck.php, line 44

Class

RegistrationLinkAccessCheck
Access check for user registration routes.

Namespace

Drupal\registration_link\Access

Code

public function access(AccountInterface $account) {
  if (in_array('administrator', $account
    ->getRoles())) {
    return AccessResult::allowed();
  }
  return AccessResult::allowedIf($account
    ->isAnonymous() && $this->configFactory
    ->get('register') != UserInterface::REGISTER_ADMINISTRATORS_ONLY)
    ->addCacheableDependency($this->configFactory);
}