public function ConfigInspectorController::overview in Configuration Inspector 8
Builds a page listing all configuration keys to inspect.
Return value
array A render array representing the list.
1 string reference to 'ConfigInspectorController::overview'
File
- src/
Controller/ ConfigInspectorController.php, line 99
Class
- ConfigInspectorController
- Defines a controller for the config_inspector module.
Namespace
Drupal\config_inspector\ControllerCode
public function overview() {
$page['#attached']['library'][] = 'system/drupal.debounce';
$page['#attached']['library'][] = 'config_inspector/config_inspector';
$page['filters'] = [
'#type' => 'container',
'#attributes' => [
'class' => [
'table-filter',
'js-show',
],
],
];
$page['filters']['text'] = [
'#type' => 'search',
'#title' => $this
->t('Search'),
'#size' => 30,
'#placeholder' => $this
->t('Search for a configuration key'),
'#attributes' => [
'id' => 'schema-filter-text',
'autocomplete' => 'off',
'title' => $this
->t('Enter a part of the configuration key to filter by.'),
],
];
$page['filters']['schema_has_errors'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Only show errors'),
'#label_attributes' => [
'for' => 'schema-has-errors',
],
'#attributes' => [
'id' => 'schema-has-errors',
],
];
$page['table'] = [
'#type' => 'table',
'#header' => [
'name' => $this
->t('Configuration key'),
'schema' => $this
->t('Schema'),
'list' => $this
->t('List'),
'tree' => $this
->t('Tree'),
'form' => $this
->t('Form'),
'raw' => $this
->t('Raw data'),
'download' => $this
->t('Download'),
],
'#attributes' => [
'class' => [
'config-inspector-list',
],
],
];
foreach ($this->configStorage
->listAll() as $name) {
$label = '<span class="table-filter-text-source">' . $name . '</span>';
// Elements without a schema are displayed to help debugging.
if (!$this->configInspectorManager
->hasSchema($name)) {
$page['table'][] = [
'name' => [
'#markup' => $label,
],
'schema' => [
'#markup' => $this
->t('None'),
'#wrapper_attributes' => [
'data-has-errors' => TRUE,
],
],
'list' => [
'#markup' => $this
->t('N/A'),
],
'tree' => [
'#markup' => $this
->t('N/A'),
],
'form' => [
'#markup' => $this
->t('N/A'),
],
'raw' => Link::createFromRoute($this
->t('Raw data'), 'config_inspector.raw_page', [
'name' => $name,
])
->toRenderable(),
'download' => Link::createFromRoute($this
->t('Download'), 'config_inspector.download', [
'name' => $name,
])
->toRenderable(),
];
}
else {
$schema = $this
->t('Correct');
$result = $this->configInspectorManager
->checkValues($name);
if (is_array($result)) {
// The no-schema case is covered above already, if we got errors, the
// schema is partial.
$schema = $this->translationManager
->formatPlural(count($result), '@count error', '@count errors');
}
$page['table'][] = [
'name' => [
'#markup' => $label,
],
'schema' => [
'#markup' => $schema,
'#wrapper_attributes' => [
'data-has-errors' => is_array($result),
],
],
'list' => [
'#markup' => Link::createFromRoute($this
->t('List'), 'config_inspector.list_page', [
'name' => $name,
])
->toString(),
],
'tree' => [
'#markup' => Link::createFromRoute($this
->t('Tree'), 'config_inspector.tree_page', [
'name' => $name,
])
->toString(),
],
'form' => [
'#markup' => Link::createFromRoute($this
->t('Form'), 'config_inspector.form_page', [
'name' => $name,
])
->toString(),
],
'raw' => [
'#markup' => Link::createFromRoute($this
->t('Raw data'), 'config_inspector.raw_page', [
'name' => $name,
])
->toString(),
],
'download' => [
'#markup' => Link::createFromRoute($this
->t('Download'), 'config_inspector.download', [
'name' => $name,
])
->toString(),
],
];
}
}
return $page;
}