You are here

public function DomainConfigUIController::overview in Domain Access 8

Lists all stored configuration.

1 string reference to 'DomainConfigUIController::overview'
domain_config_ui.routing.yml in domain_config_ui/domain_config_ui.routing.yml
domain_config_ui/domain_config_ui.routing.yml

File

domain_config_ui/src/Controller/DomainConfigUIController.php, line 86

Class

DomainConfigUIController
Controller routines for AJAX callbacks for domain actions.

Namespace

Drupal\domain_config_ui\Controller

Code

public function overview() {
  $elements = [];
  $page['table'] = [
    '#type' => 'table',
    '#header' => [
      'name' => t('Configuration key'),
      'item' => t('Item'),
      'domain' => t('Domain'),
      'language' => t('Language'),
      'actions' => t('Actions'),
    ],
  ];

  // @TODO: inject services.
  $storage = \Drupal::service('config.storage');
  foreach ($storage
    ->listAll('domain.config') as $name) {
    $elements[] = $this
      ->deriveElements($name);
  }

  // Sort the items.
  if (!empty($elements)) {
    uasort($elements, [
      $this,
      'sortItems',
    ]);
    foreach ($elements as $element) {
      $operations = [
        'inspect' => [
          'url' => Url::fromRoute('domain_config_ui.inspect', [
            'config_name' => $element['name'],
          ]),
          'title' => $this
            ->t('Inspect'),
        ],
        'delete' => [
          'url' => Url::fromRoute('domain_config_ui.delete', [
            'config_name' => $element['name'],
          ]),
          'title' => $this
            ->t('Delete'),
        ],
      ];
      $page['table'][] = [
        'name' => [
          '#markup' => $element['name'],
        ],
        'item' => [
          '#markup' => $element['item'],
        ],
        'domain' => [
          '#markup' => $element['domain'],
        ],
        'language' => [
          '#markup' => $element['language'],
        ],
        'actions' => [
          '#type' => 'operations',
          '#links' => $operations,
        ],
      ];
    }
  }
  else {
    $page = [
      '#markup' => $this
        ->t('No domain-specific configurations have been found.'),
    ];
  }
  return $page;
}