You are here

function domain_entity_domain_references_alter in Domain Access Entity 8

Implements hook_domain_references_alter().

File

./domain_entity.module, line 560
Enables domain access for entities, and access query alter.

Code

function domain_entity_domain_references_alter($query, $account, $context) {
  if ($account
    ->hasPermission('publish to any domain')) {
    return;
  }

  // Limit list of domains that can be used by requested user.
  $allowed = \Drupal::service('domain_access.manager')
    ->getAccessValues($account);
  $query
    ->condition('id', array_keys($allowed), 'IN');
}