You are here

public function AdministrationForm::submitForm in Google Search Appliance 8

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 ConfigFormBase::submitForm

File

src/Form/AdministrationForm.php, line 269

Class

AdministrationForm
Class AdministrationForm.

Namespace

Drupal\google_appliance\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $oneboxValue = explode("\n", $form_state
    ->getValue('onebox_modules'));
  $oneboxValue = array_map('trim', $oneboxValue);
  $oneboxValue = array_filter($oneboxValue, 'strlen');
  $this->configFactory
    ->getEditable($this
    ->getEditableConfigNames())
    ->set('connection_info.hostname', $form_state
    ->getValue('hostname'))
    ->set('connection_info.collection', $form_state
    ->getValue('collection'))
    ->set('connection_info.frontend', $form_state
    ->getValue('frontend'))
    ->set('connection_info.timeout', $form_state
    ->getValue('timeout'))
    ->set('query_param.autofilter', $form_state
    ->getValue('autofilter'))
    ->set('query_param.query_inspection', $form_state
    ->getValue('query_inspection'))
    ->set('display_settings.drupal_path', trim($form_state
    ->getValue('drupal_path'), '/'))
    ->set('display_settings.search_title', $form_state
    ->getValue('search_title'))
    ->set('display_settings.results_per_page', $form_state
    ->getValue('results_per_page'))
    ->set('display_settings.spelling_suggestions', $form_state
    ->getValue('spelling_suggestions'))
    ->set('display_settings.advanced_search_reporting', $form_state
    ->getValue('advanced_search_reporting'))
    ->set('display_settings.sitelinks_search_box', $form_state
    ->getValue('sitelinks_search_box'))
    ->set('display_settings.onebox_modules', $oneboxValue)
    ->set('display_settings.error_gsa_no_results', $form_state
    ->getValue('error_gsa_no_results'))
    ->set('display_settings.error_curl_error', $form_state
    ->getValue('error_curl_error'))
    ->set('display_settings.error_lib_xml_parse_error', $form_state
    ->getValue('error_lib_xml_parse_error'))
    ->save();
  $this->routeBuilder
    ->rebuild();
  parent::submitForm($form, $form_state);
}