function ConfigDeleteForm::submitForm

Same name and namespace in other branches
  1. 5.x src/Form/ConfigDeleteForm.php \Drupal\devel\Form\ConfigDeleteForm::submitForm()

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

src/Form/ConfigDeleteForm.php, line 65

Class

ConfigDeleteForm
Edit config variable form.

Namespace

Drupal\devel\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config_name = $form_state->getValue('name');
  try {
    $this->configFactory()
      ->getEditable($config_name)
      ->delete();
    $this->messenger()
      ->addStatus($this->t('Configuration variable %variable was successfully deleted.', [
      '%variable' => $config_name,
    ]));
    $this->logger('devel')
      ->info('Configuration variable %variable was successfully deleted.', [
      '%variable' => $config_name,
    ]);
    $form_state->setRedirectUrl($this->getCancelUrl());
  } catch (\Exception $e) {
    $this->messenger()
      ->addError($e->getMessage());
    $this->logger('devel')
      ->error('Error deleting configuration variable %variable : %error.', [
      '%variable' => $config_name,
      '%error' => $e->getMessage(),
    ]);
  }
}