You are here

public function DomainContentController::buildList in Domain Access 8

Builds the list of domains and relevant entities.

Parameters

array $options: A list of variables required to build editor or content pages.

Return value

array A Drupal page build array.

See also

contentlist()

2 calls to DomainContentController::buildList()
DomainContentController::contentList in domain_content/src/Controller/DomainContentController.php
Generates a list of content by domain.
DomainContentController::editorsList in domain_content/src/Controller/DomainContentController.php
Generates a list of editors by domain.

File

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

Class

DomainContentController
Controller routines domain content pages.

Namespace

Drupal\domain_content\Controller

Code

public function buildList(array $options) {
  $account = $this
    ->getUser();
  $build = [
    '#theme' => 'table',
    '#header' => [
      $this
        ->t('Domain'),
      $options['column_header'],
    ],
  ];
  if ($account
    ->hasPermission($options['all_permission'])) {
    $build['#rows'][] = [
      Link::fromTextAndUrl($this
        ->t('All affiliates'), Url::fromUri('internal:/admin/content/' . $options['path'] . '/all_affiliates')),
      $this
        ->getCount($options['type']),
    ];
  }

  // Loop through domains.
  $domains = \Drupal::entityTypeManager()
    ->getStorage('domain')
    ->loadMultipleSorted();
  $manager = \Drupal::service('domain_access.manager');

  /** @var \Drupal\domain\DomainInterface $domain */
  foreach ($domains as $domain) {
    if ($account
      ->hasPermission($options['all_permission']) || $manager
      ->hasDomainPermissions($account, $domain, [
      $options['permission'],
    ])) {
      $row = [
        Link::fromTextAndUrl($domain
          ->label(), Url::fromUri('internal:/admin/content/' . $options['path'] . '/' . $domain
          ->id())),
        $this
          ->getCount($options['type'], $domain),
      ];
      $build['#rows'][] = $row;
    }
  }
  return $build;
}