You are here

public function SearchPageListBuilder::submitForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/search/src/SearchPageListBuilder.php \Drupal\search\SearchPageListBuilder::submitForm()
  2. 10 core/modules/search/src/SearchPageListBuilder.php \Drupal\search\SearchPageListBuilder::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 DraggableListBuilder::submitForm

File

core/modules/search/src/SearchPageListBuilder.php, line 349

Class

SearchPageListBuilder
Defines a class to build a listing of search page entities.

Namespace

Drupal\search

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  parent::submitForm($form, $form_state);
  $search_settings = $this
    ->config('search.settings');

  // If these settings change, the default index needs to be rebuilt.
  if ($search_settings
    ->get('index.minimum_word_size') != $form_state
    ->getValue('minimum_word_size') || $search_settings
    ->get('index.overlap_cjk') != $form_state
    ->getValue('overlap_cjk')) {
    $search_settings
      ->set('index.minimum_word_size', $form_state
      ->getValue('minimum_word_size'));
    $search_settings
      ->set('index.overlap_cjk', $form_state
      ->getValue('overlap_cjk'));

    // Specifically mark items in the default index for reindexing, since
    // these settings are used in the SearchIndex::index() function.
    $this->messenger
      ->addStatus($this
      ->t('The default search index will be rebuilt.'));
    $this->searchIndex
      ->markForReindex();
  }
  $search_settings
    ->set('index.cron_limit', $form_state
    ->getValue('cron_limit'))
    ->set('logging', $form_state
    ->getValue('logging'))
    ->save();
  $this->messenger
    ->addStatus($this
    ->t('The configuration options have been saved.'));
}