public function UserRegisterBlock::blockAccess in Form Block 2.0.x
Same name and namespace in other branches
- 8 src/Plugin/Block/UserRegisterBlock.php \Drupal\formblock\Plugin\Block\UserRegisterBlock::blockAccess()
The intention here is to fulfil the block settings and honour the site wide config at /admin/config/people/accounts on who can register new accounts and not to enforce through hard coded decisions.
Overrides BlockPluginTrait::blockAccess
File
- src/
Plugin/ Block/ UserRegisterBlock.php, line 174
Class
- UserRegisterBlock
- Provides a block for the user registration form.
Namespace
Drupal\formblock\Plugin\BlockCode
public function blockAccess(AccountInterface $account) {
$evaluate = TRUE;
if (!in_array('administrator', $account
->getRoles()) && $this->configFactory
->get('user.settings')
->get('register') === UserInterface::REGISTER_ADMINISTRATORS_ONLY) {
$evaluate = FALSE;
}
return AccessResult::allowedIf($evaluate)
->addCacheContexts([
'user.roles',
])
->addCacheTags($this->configFactory
->get('user.settings')
->getCacheTags());
}