You are here

public function ConfigForm::submitForm in Restrict IP 8

Same name and namespace in other branches
  1. 8.2 src/Form/ConfigForm.php \Drupal\restrict_ip\Form\ConfigForm::submitForm()
  2. 3.x src/Form/ConfigForm.php \Drupal\restrict_ip\Form\ConfigForm::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/ConfigForm.php, line 378

Class

ConfigForm

Namespace

Drupal\restrict_ip\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $this
    ->config('restrict_ip.settings')
    ->set('enable', (bool) $form_state
    ->getValue('enable'))
    ->set('mail_address', (string) $form_state
    ->getValue('mail_address'))
    ->set('dblog', (bool) $form_state
    ->getValue('dblog'))
    ->set('allow_role_bypass', (bool) $form_state
    ->getValue('allow_role_bypass'))
    ->set('bypass_action', (string) $form_state
    ->getValue('bypass_action'))
    ->set('white_black_list', (int) $form_state
    ->getValue('white_black_list'))
    ->save();
  $this->restrictIpService
    ->saveWhitelistedIpAddresses($this->restrictIpService
    ->cleanIpAddressInput($form_state
    ->getValue('address_list')));
  $this->restrictIpService
    ->saveWhitelistedPagePaths($form_state
    ->getValue('page_whitelist'));
  $this->restrictIpService
    ->saveBlacklistedPagePaths($form_state
    ->getValue('page_blacklist'));
  parent::submitForm($form, $form_state);
}