function domain_entity_get_user_domains in Domain Access Entity 8
Returns the list domains for user.
Parameters
\Drupal\Core\Session\AccountInterface $account: Drupal user account.
Return value
\Drupal\domain\DomainInterface[] List of domains.
1 call to domain_entity_get_user_domains()
- domain_entity_get_user_available_domains in ./
domain_entity.module - Return a list of domain id's, accessible by the current user.
File
- ./
domain_entity.module, line 125 - Enables domain access for entities, and access query alter.
Code
function domain_entity_get_user_domains(AccountInterface $account = NULL) {
if (!isset($account)) {
$account = \Drupal::currentUser();
}
$user = User::load($account
->id());
$user_domains = [];
foreach ($user
->get(DOMAIN_ADMIN_FIELD) as $item) {
$user_domains[] = $item->entity
->id();
}
return $user_domains;
}