public function SwitchForm::canUseDomainConfig in Domain Access 8
Determines if a user may access the domain-sensitive form.
1 call to SwitchForm::canUseDomainConfig()
- SwitchForm::buildForm in domain_config_ui/
src/ Form/ SwitchForm.php - Form constructor.
File
- domain_config_ui/
src/ Form/ SwitchForm.php, line 84
Class
- SwitchForm
- Class SwitchForm.
Namespace
Drupal\domain_config_ui\FormCode
public function canUseDomainConfig() {
if ($this
->currentUser()
->hasPermission('administer domains')) {
$user_domains = 'all';
}
else {
$account = $this
->currentUser();
$user = $this->entityTypeManager
->getStorage('user')
->load($account
->id());
$user_domains = $this->domainElementManager
->getFieldValues($user, DomainInterface::DOMAIN_ADMIN_FIELD);
}
$permission = $this
->currentUser()
->hasPermission('use domain config ui') || $this
->currentUser()
->hasPermission('administer domain config ui');
return !empty($user_domains) && $permission;
}