public function ConfigForm::submitForm in Restrict IP 3.x
Same name and namespace in other branches
- 8.2 src/Form/ConfigForm.php \Drupal\restrict_ip\Form\ConfigForm::submitForm()
- 8 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 433
Class
Namespace
Drupal\restrict_ip\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
if ($this->moduleHandler
->moduleExists('ip2country')) {
$countries = [];
foreach ($form_state
->getValue('country_list') as $country) {
if ($country) {
$countries[] = $country;
}
}
$country_list = implode(':', $countries);
}
else {
$country_list = '';
}
$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'))
->set('country_white_black_list', (int) $form_state
->getValue('country_white_black_list'))
->set('country_list', $country_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);
}