You are here

public static function DomainConfigUIController::deriveElements in Domain Access 8

Derives the parts of a config object for presentation.

Parameters

string $name: A configuration object name.

Return value

array An array of config values, keyed by name.

3 calls to DomainConfigUIController::deriveElements()
DeleteForm::buildForm in domain_config_ui/src/Form/DeleteForm.php
Build configuration form with metadata and values.
DomainConfigUIController::inspectConfig in domain_config_ui/src/Controller/DomainConfigUIController.php
Controller for inspecting configuration.
DomainConfigUIController::overview in domain_config_ui/src/Controller/DomainConfigUIController.php
Lists all stored configuration.

File

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

Class

DomainConfigUIController
Controller routines for AJAX callbacks for domain actions.

Namespace

Drupal\domain_config_ui\Controller

Code

public static function deriveElements($name) {
  $entity_manager = \Drupal::entityTypeManager();
  $items = explode('.', $name);
  $elements = [
    'prefix' => $items[0],
    'config' => isset($items[1]) && isset($items[2]) ? $items[1] : '',
    'domain' => isset($items[2]) && isset($items[3]) ? $items[2] : '',
    'language' => isset($items[3]) && isset($items[4]) && strlen($items[3]) == 2 ? $items[3] : '',
  ];
  $elements['item'] = trim(str_replace($elements, '', $name), '.');
  if (!empty($elements['domain']) && ($domain = $entity_manager
    ->getStorage('domain')
    ->load($elements['domain']))) {
    $elements['domain'] = $domain
      ->label();
  }
  if (!$elements['language']) {

    // Static context requires use of t() here.
    $elements['language'] = t('all')
      ->render();
  }
  elseif ($language = \Drupal::languageManager()
    ->getLanguage($elements['language'])) {
    $elements['language'] = $language
      ->getName();
  }
  $elements['name'] = $name;
  return $elements;
}