class RegistrationLinkAccessCheck in Registration Link 8.2
Access check for user registration routes.
@package Drupal\registration_link\Access
Hierarchy
- class \Drupal\registration_link\Access\RegistrationLinkAccessCheck implements AccessInterface
Expanded class hierarchy of RegistrationLinkAccessCheck
1 string reference to 'RegistrationLinkAccessCheck'
1 service uses RegistrationLinkAccessCheck
File
- src/
Access/ RegistrationLinkAccessCheck.php, line 16
Namespace
Drupal\registration_link\AccessView source
class RegistrationLinkAccessCheck implements AccessInterface {
/**
* The Config Factory service.
*
* @var \Drupal\Core\Config\ConfigFactory
*/
protected $configFactory;
/**
* RegistrationLinkAccessCheck constructor.
*
* @param \Drupal\Core\Config\ConfigFactory $configFactory
* The Config Factory service.
*/
public function __construct(ConfigFactory $configFactory) {
$this->configFactory = $configFactory
->get('user.settings');
}
/**
* Checks access.
*
* @param \Drupal\Core\Session\AccountInterface $account
* The currently logged in account.
*
* @return $this|\Drupal\Core\Access\AccessResultAllowed
* The access result.
*/
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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RegistrationLinkAccessCheck:: |
protected | property | The Config Factory service. | |
RegistrationLinkAccessCheck:: |
public | function | Checks access. | |
RegistrationLinkAccessCheck:: |
public | function | RegistrationLinkAccessCheck constructor. |