You are here

public function BlockDeleteForm::submitForm in Context 8

Same name and namespace in other branches
  1. 8.4 src/Reaction/Blocks/Form/BlockDeleteForm.php \Drupal\context\Reaction\Blocks\Form\BlockDeleteForm::submitForm()
  2. 8.0 src/Reaction/Blocks/Form/BlockDeleteForm.php \Drupal\context\Reaction\Blocks\Form\BlockDeleteForm::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

src/Reaction/Blocks/Form/BlockDeleteForm.php, line 119

Class

BlockDeleteForm

Namespace

Drupal\context\Reaction\Blocks\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $configuration = $this->block
    ->getConfiguration();
  $this->reaction
    ->removeBlock($configuration['uuid']);
  $this->context
    ->save();

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