You are here

public function DeleteMultiple::submitForm in Message 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/DeleteMultiple.php, line 111

Class

DeleteMultiple
Provides a message deletion confirmation form.

Namespace

Drupal\message\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  if ($form_state
    ->getValue('confirm') && !empty($this->messages)) {
    $this->storage
      ->delete($this->messages);
    $this->tempStoreFactory
      ->get('message_multiple_delete_confirm')
      ->delete(\Drupal::currentUser()
      ->id());
    $count = count($this->messages);
    $this
      ->logger('message')
      ->notice('Deleted @count messages.', [
      '@count' => $count,
    ]);
    $this
      ->messenger()
      ->addMessage(\Drupal::translation()
      ->formatPlural($count, 'Deleted 1 message.', 'Deleted @count messages.'));
  }
  $form_state
    ->setRedirect('message.messages');
}