You are here

protected function DomainCommands::enumerateDomainEntities in Domain Access 8

Enumerate entity instances of the supplied type and domain.

Parameters

string $entity_type: The entity type name, e.g. 'node'.

string $domain_id: The machine name of the domain to enumerate.

string $field: The field to manipulate in the entity, e.g. DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD.

bool $just_count: Flag to return a count rather than a list.

Return value

int|string[] List of entity IDs for the selected domain or a count of domains.

1 call to DomainCommands::enumerateDomainEntities()
DomainCommands::reassignLinkedEntities in domain/src/Commands/DomainCommands.php
Reassign entities of the supplied type to the $policy domain.

File

domain/src/Commands/DomainCommands.php, line 1247

Class

DomainCommands
Drush commands for the domain module.

Namespace

Drupal\domain\Commands

Code

protected function enumerateDomainEntities($entity_type, $domain_id, $field, $just_count = FALSE) {
  if (!$this
    ->entityHasDomainField($entity_type, $field)) {
    $this
      ->logger()
      ->info('Entity type @entity_type does not have field @field, so none found.', [
      '@entity_type' => $entity_type,
      '@field' => $field,
    ]);
    return [];
  }
  $efq = \Drupal::entityQuery($entity_type);

  // Don't access check or we wont get all of the possible entities moved.
  $efq
    ->accessCheck(FALSE);
  $efq
    ->condition($field, $domain_id, '=');
  if ($just_count) {
    $efq
      ->count();
  }
  return $efq
    ->execute();
}