You are here

protected function DomainContentController::getCount in Domain Access 8

Counts the content for a domain.

Parameters

string $entity_type: The entity type.

\Drupal\domain\DomainInterface $domain: The domain to query. If passed NULL, checks status for all affiliates.

Return value

int The content count for the given domain.

1 call to DomainContentController::getCount()
DomainContentController::buildList in domain_content/src/Controller/DomainContentController.php
Builds the list of domains and relevant entities.

File

domain_content/src/Controller/DomainContentController.php, line 96

Class

DomainContentController
Controller routines domain content pages.

Namespace

Drupal\domain_content\Controller

Code

protected function getCount($entity_type = 'node', DomainInterface $domain = NULL) {
  if (is_null($domain)) {
    $field = DomainAccessManagerInterface::DOMAIN_ACCESS_ALL_FIELD;
    $value = 1;
  }
  else {
    $field = DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD;
    $value = $domain
      ->id();
  }

  // Note that we ignore node access so these queries work on any domain.
  $query = \Drupal::entityQuery($entity_type)
    ->condition($field, $value)
    ->accessCheck(FALSE);
  return count($query
    ->execute());
}