public function DomainAccessManager::checkEntityAccess in Domain Access 8
Compare the entity values against a user's account assignments.
Parameters
\Drupal\Core\Entity\FieldableEntityInterface $entity: The entity being checked for access.
\Drupal\Core\Session\AccountInterface $account: The account of the user performing the action.
Return value
bool Returns TRUE if the user has access to the domain.
Overrides DomainAccessManagerInterface::checkEntityAccess
File
- domain_access/
src/ DomainAccessManager.php, line 101
Class
- DomainAccessManager
- Checks the access status of entities based on domain settings.
Namespace
Drupal\domain_accessCode
public function checkEntityAccess(FieldableEntityInterface $entity, AccountInterface $account) {
$entity_domains = $this
->getAccessValues($entity);
$user = \Drupal::entityTypeManager()
->getStorage('user')
->load($account
->id());
if (!empty($this
->getAllValue($user)) && !empty($entity_domains)) {
return TRUE;
}
$user_domains = $this
->getAccessValues($user);
return (bool) (!empty(array_intersect($entity_domains, $user_domains)));
}