You are here

public function DomainAccessControlHandler::isDomainAdmin in Domain Access 8

Checks if a user can administer a specific domain.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to retrieve field data from.

\Drupal\Core\Session\AccountInterface $account: The user account.

Return value

bool TRUE if a user can administer a specific domain, or FALSE.

2 calls to DomainAccessControlHandler::isDomainAdmin()
DomainAccessControlHandler::checkAccess in domain/src/DomainAccessControlHandler.php
Performs access checks.
DomainAliasAccessControlHandler::checkAccess in domain_alias/src/DomainAliasAccessControlHandler.php
Performs access checks.

File

domain/src/DomainAccessControlHandler.php, line 120

Class

DomainAccessControlHandler
Defines the access controller for the domain entity type.

Namespace

Drupal\domain

Code

public function isDomainAdmin(EntityInterface $entity, AccountInterface $account) {
  $user = $this->userStorage
    ->load($account
    ->id());
  $user_domains = $this->domainElementManager
    ->getFieldValues($user, DomainInterface::DOMAIN_ADMIN_FIELD);
  return isset($user_domains[$entity
    ->id()]);
}