public function SearchSettingsForm::submitForm

Implements \Drupal\Core\Form\FormInterface::submitForm().

Overrides SystemConfigFormBase::submitForm

File

drupal/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php, line 208
Contains \Drupal\search\Form\SearchSettingsForm.

Class

SearchSettingsForm
Configure search settings for this site.

Namespace

Drupal\search\Form

Code

public function submitForm(array &$form, array &$form_state) {
  parent::submitForm($form, $form_state);

  // If these settings change, the index needs to be rebuilt.
  if ($this->searchSettings
    ->get('index.minimum_word_size') != $form_state['values']['minimum_word_size'] || $this->searchSettings
    ->get('index.overlap_cjk') != $form_state['values']['overlap_cjk']) {
    $this->searchSettings
      ->set('index.minimum_word_size', $form_state['values']['minimum_word_size']);
    $this->searchSettings
      ->set('index.overlap_cjk', $form_state['values']['overlap_cjk']);
    drupal_set_message(t('The index will be rebuilt.'));
    search_reindex();
  }
  $this->searchSettings
    ->set('index.cron_limit', $form_state['values']['cron_limit']);
  $this->searchSettings
    ->set('default_module', $form_state['values']['default_module']);

  // Check whether we are resetting the values.
  if ($form_state['triggering_element']['#value'] == t('Reset to defaults')) {
    $new_modules = array(
      'node',
      'user',
    );
  }
  else {
    $new_modules = array_filter($form_state['values']['active_modules']);
  }
  if ($this->searchSettings
    ->get('active_modules') != $new_modules) {
    $this->searchSettings
      ->set('active_modules', $new_modules);
    drupal_set_message(t('The active search modules have been changed.'));
    $this->state
      ->set('menu_rebuild_needed', TRUE);
  }
  $this->searchSettings
    ->save();
}