You are here

public function IndexFieldsForm::cancel in Search API 8

Cancels the editing of the index's fields.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

File

src/Form/IndexFieldsForm.php, line 513

Class

IndexFieldsForm
Provides a form for configuring the fields of a search index.

Namespace

Drupal\search_api\Form

Code

public function cancel(array &$form, FormStateInterface $form_state) {
  if ($this->entity instanceof UnsavedConfigurationInterface && $this->entity
    ->hasChanges()) {
    $this->entity
      ->discardChanges();
  }
  $form_state
    ->setRedirectUrl($this->entity
    ->toUrl('canonical'));
}