You are here

public function RateSettingsForm::submitForm in Rate 8.2

Same name and namespace in other branches
  1. 8 src/Form/RateSettingsForm.php \Drupal\rate\Form\RateSettingsForm::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 ConfigFormBase::submitForm

File

src/Form/RateSettingsForm.php, line 177

Class

RateSettingsForm
Configure rate settings for the site.

Namespace

Drupal\rate\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('rate.settings');
  if ((bool) $config
    ->get('disable_log') !== (bool) $form_state
    ->getValue('disable_log')) {
    $config
      ->set('disable_log', $form_state
      ->getValue('disable_log'))
      ->save();
  }
  if ((bool) $config
    ->get('disable_fontawesome') !== (bool) $form_state
    ->getValue('disable_fontawesome')) {
    $config
      ->set('disable_fontawesome', $form_state
      ->getValue('disable_fontawesome'))
      ->save();
    Cache::invalidateTags([
      'library_info',
    ]);
  }
  $config
    ->set('bot_minute_threshold', $form_state
    ->getValue('bot_minute_threshold'))
    ->set('bot_hour_threshold', $form_state
    ->getValue('bot_hour_threshold'))
    ->set('botscout_key', $form_state
    ->getValue('botscout_key'))
    ->save();
  parent::submitForm($form, $form_state);
}