function ConfigsList::buildForm
Same name in other branches
- 4.x src/Form/ConfigsList.php \Drupal\devel\Form\ConfigsList::buildForm()
Overrides FormInterface::buildForm
File
-
src/
Form/ ConfigsList.php, line 38
Class
- ConfigsList
- Form that displays all the config variables to edit them.
Namespace
Drupal\devel\FormCode
public function buildForm(array $form, FormStateInterface $form_state, $filter = '') : array {
$form['filter'] = [
'#type' => 'details',
'#title' => $this->t('Filter variables'),
'#attributes' => [
'class' => [
'container-inline',
],
],
'#open' => isset($filter) && trim($filter) !== '',
];
$form['filter']['name'] = [
'#type' => 'textfield',
'#title' => $this->t('Variable name'),
'#title_display' => 'invisible',
'#default_value' => $filter,
];
$form['filter']['actions'] = [
'#type' => 'actions',
];
$form['filter']['actions']['show'] = [
'#type' => 'submit',
'#value' => $this->t('Filter'),
];
$header = [
'name' => [
'data' => $this->t('Name'),
],
'edit' => [
'data' => $this->t('Operations'),
],
];
$rows = [];
$destination = $this->redirectDestination
->getAsArray();
// List all the variables filtered if any filter was provided.
$names = $this->configFactory
->listAll($filter);
foreach ($names as $config_name) {
$operations['edit'] = [
'title' => $this->t('Edit'),
'url' => Url::fromRoute('devel.config_edit', [
'config_name' => $config_name,
]),
'query' => $destination,
];
$rows[] = [
'name' => $config_name,
'operation' => [
'data' => [
'#type' => 'operations',
'#links' => $operations,
],
],
];
}
$form['variables'] = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => $this->t('No variables found'),
];
return $form;
}