You are here

public function OutdatedbrowserSettingsForm::submitForm in Outdated Browser 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/OutdatedbrowserSettingsForm.php, line 90
Administrative class form for the outdatedbrowser module.

Class

OutdatedbrowserSettingsForm
General configuration form for controlling the outdatedbrowser behaviour..

Namespace

Drupal\outdatedbrowser\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Get config factory and load all settings.
  $config = $this->configFactory
    ->getEditable('outdatedbrowser.settings');
  $compression_type_changed = $config
    ->get('compression_type') != $form_state
    ->getValue('outdatedbrowser_compression_type');
  if ($compression_type_changed) {

    // Invalidate the library_info cache.
    \Drupal::cache('discovery')
      ->invalidate('library_info');
  }
  $config
    ->set('compression_type', $form_state
    ->getValue('outdatedbrowser_compression_type'))
    ->set('bgcolor', $form_state
    ->getValue('outdatedbrowser_bgcolor'))
    ->set('color', $form_state
    ->getValue('outdatedbrowser_color'))
    ->set('lowerthan', $form_state
    ->getValue('outdatedbrowser_lowerthan'))
    ->set('lang_files_path', $form_state
    ->getValue('outdatedbrowser_lang_files_path'));
  $config
    ->save();
  parent::submitForm($form, $form_state);
}