public function DomainAccessCheck::access in Domain Access 8
File
- domain/
src/ Access/ DomainAccessCheck.php, line 73
Class
- DomainAccessCheck
- Provides a global access check to ensure inactive domains are restricted.
Namespace
Drupal\domain\AccessCode
public function access(AccountInterface $account) {
$domain = $this->domainNegotiator
->getActiveDomain();
// Is the domain allowed?
// No domain, let it pass.
if (empty($domain)) {
return AccessResult::allowed()
->addCacheTags([
'url.site',
]);
}
// Active domain, let it pass.
if ($domain
->status()) {
return AccessResult::allowed()
->addCacheTags([
'url.site',
]);
}
else {
$permissions = [
'administer domains',
'access inactive domains',
];
$operator = 'OR';
return AccessResult::allowedIfHasPermissions($account, $permissions, $operator)
->addCacheTags([
'url.site',
]);
}
}