You are here

public function DblogClearLogConfirmForm::submitForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/dblog/src/Form/DblogClearLogConfirmForm.php \Drupal\dblog\Form\DblogClearLogConfirmForm::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

core/modules/dblog/src/Form/DblogClearLogConfirmForm.php, line 68

Class

DblogClearLogConfirmForm
Provides a confirmation form before clearing out the logs.

Namespace

Drupal\dblog\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $this
    ->getRequest()
    ->getSession()
    ->remove('dblog_overview_filter');
  $this->connection
    ->truncate('watchdog')
    ->execute();
  $this
    ->messenger()
    ->addStatus($this
    ->t('Database log cleared.'));
  $form_state
    ->setRedirectUrl($this
    ->getCancelUrl());
}