You are here

public function FloodControlSettingsForm::submitForm in Flood control 2.0.x

Same name and namespace in other branches
  1. 1.0.x src/Form/FloodControlSettingsForm.php \Drupal\flood_control\Form\FloodControlSettingsForm::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/FloodControlSettingsForm.php, line 159

Class

FloodControlSettingsForm
Administration settings form.

Namespace

Drupal\flood_control\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $flood_config = $this->configFactory
    ->getEditable('user.flood');
  $flood_config
    ->set('ip_limit', $form_state
    ->getValue('ip_limit'))
    ->set('ip_window', $form_state
    ->getValue('ip_window'))
    ->set('user_limit', $form_state
    ->getValue('user_limit'))
    ->set('user_window', $form_state
    ->getValue('user_window'))
    ->save();
  if ($this->moduleHandler
    ->moduleExists('contact')) {
    $contact_config = $this->configFactory
      ->getEditable('contact.settings');
    $contact_config
      ->set('flood.limit', $form_state
      ->getValue('contact_threshold_limit'))
      ->set('flood.interval', $form_state
      ->getValue('contact_threshold_window'))
      ->save();
  }
  parent::submitForm($form, $form_state);
}