You are here

public function ConfigDeleteForm::submitForm in Devel 4.x

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.', array(
      '%variable' => $config_name,
    )));
    $this
      ->logger('devel')
      ->info('Configuration variable %variable was successfully deleted.', array(
      '%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.', array(
      '%variable' => $config_name,
      '%error' => $e
        ->getMessage(),
    ));
  }
}