You are here

public function ReactionDeleteForm::submitForm in Context 8.4

Same name and namespace in other branches
  1. 8 modules/context_ui/src/Form/ReactionDeleteForm.php \Drupal\context_ui\Form\ReactionDeleteForm::submitForm()
  2. 8.0 modules/context_ui/src/Form/ReactionDeleteForm.php \Drupal\context_ui\Form\ReactionDeleteForm::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

modules/context_ui/src/Form/ReactionDeleteForm.php, line 118

Class

ReactionDeleteForm
Provides a context reaction delete form.

Namespace

Drupal\context_ui\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $definition = $this->reaction
    ->getPluginDefinition();
  $this->context
    ->removeReaction($this->reaction
    ->getPluginId());
  $this->context
    ->save();

  // If this is not an AJAX request then redirect and show a message.
  if (!$this
    ->getRequest()
    ->isXmlHttpRequest()) {
    $this
      ->messenger()
      ->addMessage($this
      ->t('The %label context reaction has been removed.', [
      '%label' => $definition['label'],
    ]));
    $form_state
      ->setRedirectUrl($this
      ->getCancelUrl());
  }
}