You are here

public function IpBanAdmin::submitForm in IP Ban 8

Same name in this branch
  1. 8 src/IpBanAdmin.php \Drupal\ip_ban\IpBanAdmin::submitForm()
  2. 8 src/Form/IpBanAdmin.php \Drupal\ip_ban\Form\IpBanAdmin::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/IpBanAdmin.php, line 148

Class

IpBanAdmin

Namespace

Drupal\ip_ban\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('ip_ban.settings');
  foreach (Element::children($form) as $variable) {
    $config
      ->set($variable, $form_state
      ->getValue($form[$variable]['#parents']));
  }
  $values = $form_state
    ->getValues();
  foreach ($this->country_short_names as $csn) {
    $config
      ->set($csn, $values[$csn]);
  }
  $config
    ->save();
  if (method_exists($this, '_submitForm')) {
    $this
      ->_submitForm($form, $form_state);
  }

  // Clear the router cache because we're dealing with paths.
  \Drupal::service("router.builder")
    ->rebuild();
  parent::submitForm($form, $form_state);
}