You are here

public function RedirectDeleteMultipleForm::submitForm in Redirect 8

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/RedirectDeleteMultipleForm.php, line 128

Class

RedirectDeleteMultipleForm
Provides a redirect deletion confirmation form.

Namespace

Drupal\redirect\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  if ($form_state
    ->getValue('confirm') && !empty($this->redirects)) {
    $this->redirectStorage
      ->delete($this->redirects);
    $this->privateTempStoreFactory
      ->get('redirect_multiple_delete_confirm')
      ->delete($this->currentUser
      ->id());
    $count = count($this->redirects);
    $this
      ->logger('redirect')
      ->notice('Deleted @count redirects.', [
      '@count' => $count,
    ]);
    $this
      ->messenger()
      ->addMessage($this->stringTranslation
      ->formatPlural($count, 'Deleted 1 redirect.', 'Deleted @count redirects.'));
  }
  $form_state
    ->setRedirect('redirect.list');
}