You are here

protected function ConfigInspectorController::formatList in Configuration Inspector 8

Format config schema as list table.

Parameters

string $config_name: The config name.

array|object $config_schema: An array of config elements with key.

Return value

array The list table as a render array.

1 call to ConfigInspectorController::formatList()
ConfigInspectorController::getList in src/Controller/ConfigInspectorController.php
List (table) inspection view of the configuration.

File

src/Controller/ConfigInspectorController.php, line 314

Class

ConfigInspectorController
Defines a controller for the config_inspector module.

Namespace

Drupal\config_inspector\Controller

Code

protected function formatList($config_name, $config_schema) {
  $rows = [];
  $errors = (array) $this->configInspectorManager
    ->checkValues($config_name);
  $schema = $this->configInspectorManager
    ->convertConfigElementToList($config_schema);
  foreach ($schema as $key => $element) {
    $definition = $element
      ->getDataDefinition();
    $rows[] = [
      'class' => isset($errors[$config_name . ':' . $key]) ? [
        'config-inspector-error',
      ] : [],
      'data' => [
        [
          'class' => [
            'icon',
          ],
          'data' => '',
        ],
        $key,
        $definition['label'],
        $definition['type'],
        $this
          ->formatValue($element),
        @$errors[$config_name . ':' . $key] ?: '',
      ],
    ];
  }
  return [
    '#attached' => [
      'library' => [
        'config_inspector/config_inspector',
      ],
    ],
    '#type' => 'table',
    '#header' => [
      '',
      $this
        ->t('Name'),
      $this
        ->t('Label'),
      $this
        ->t('Type'),
      $this
        ->t('Value'),
      $this
        ->t('Error'),
    ],
    '#rows' => $rows,
  ];
}