public function SmartIpAdminSettingsForm::submitForm in Smart IP 8.4
Same name and namespace in other branches
- 8.2 src/Form/SmartIpAdminSettingsForm.php \Drupal\smart_ip\Form\SmartIpAdminSettingsForm::submitForm()
- 8.3 src/Form/SmartIpAdminSettingsForm.php \Drupal\smart_ip\Form\SmartIpAdminSettingsForm::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/ SmartIpAdminSettingsForm.php, line 457 - Contains \Drupal\smart_ip\Form\SmartIpAdminSettingsForm.
Class
- SmartIpAdminSettingsForm
- Smart IP main admin settings page.
Namespace
Drupal\smart_ip\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$rolesDebug = [];
$rolesDebugIp = [];
$roles = Role::loadMultiple();
/** @var \Drupal\user\Entity\Role $role */
foreach ($roles as $roleId => $role) {
$rolesDebug[$roleId] = $form_state
->getValue("smart_ip_debug_{$roleId}") ? $roleId : FALSE;
$rolesDebugIp[$roleId] = $form_state
->getValue("smart_ip_test_ip_address_{$roleId}");
}
$this
->config('smart_ip.settings')
->set('data_source', $form_state
->getValue('smart_ip_data_source'))
->set('roles_to_geolocate', $form_state
->getValue('smart_ip_roles_to_geolocate'))
->set('save_user_location_creation', $form_state
->getValue('smart_ip_save_user_location_creation'))
->set('eu_visitor_dont_save', $form_state
->getValue('smart_ip_eu_visitor_dont_save'))
->set('timezone_format', $form_state
->getValue('smart_ip_timezone_format'))
->set('roles_in_debug_mode', $rolesDebug)
->set('roles_in_debug_mode_ip', $rolesDebugIp)
->set('allowed_pages', $form_state
->getValue('smart_ip_allowed_pages'))
->set('excluded_ips', $form_state
->getValue('smart_ip_excluded_ips'))
->save();
/** @var \Drupal\smart_ip\AdminSettingsEvent $event */
$event = \Drupal::service('smart_ip.admin_settings_event');
// Allow Smart IP source module to add submission on their form elements.
$event
->setForm($form);
$event
->setFormState($form_state);
\Drupal::service('event_dispatcher')
->dispatch(SmartIpEvents::SUBMIT_SETTINGS, $event);
$form = $event
->getForm();
}