You are here

public function SearchApiPageDeleteForm::submitForm in Search API Pages 8

Overrides EntityDeleteFormTrait::submitForm

File

src/Form/SearchApiPageDeleteForm.php, line 38

Class

SearchApiPageDeleteForm
Builds the form to delete Search page entities.

Namespace

Drupal\search_api_page\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $this->entity
    ->delete();
  $this
    ->messenger()
    ->addMessage($this
    ->t('@search_page_page_label has been deleted.', [
    '@search_page_page_label' => $this->entity
      ->label(),
  ]));

  // Trigger router rebuild.
  \Drupal::service('router.builder')
    ->rebuild();
  $form_state
    ->setRedirectUrl($this
    ->getCancelUrl());
}