function ConfigEditor::submitForm
Same name in other branches
- 8.x-1.x src/Form/ConfigEditor.php \Drupal\devel\Form\ConfigEditor::submitForm()
- 4.x src/Form/ConfigEditor.php \Drupal\devel\Form\ConfigEditor::submitForm()
Overrides FormInterface::submitForm
File
-
src/
Form/ ConfigEditor.php, line 149
Class
- ConfigEditor
- Edit config variable form.
Namespace
Drupal\devel\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) : void {
$values = $form_state->getValues();
try {
$this->configFactory
->getEditable($values['name'])
->setData($values['parsed_value'])
->save();
$this->messenger
->addMessage($this->t('Configuration variable %variable was successfully saved.', [
'%variable' => $values['name'],
]));
$this->logger
->info('Configuration variable %variable was successfully saved.', [
'%variable' => $values['name'],
]);
$form_state->setRedirectUrl(Url::fromRoute('devel.configs_list'));
} catch (\Exception $e) {
$this->messenger
->addError($e->getMessage());
$this->logger
->error('Error saving configuration variable %variable : %error.', [
'%variable' => $values['name'],
'%error' => $e->getMessage(),
]);
}
}