You are here

public function SmartIpEventSubscriber::submitFormSettings in Smart IP 8.3

Same name in this branch
  1. 8.3 modules/device_geolocation/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\device_geolocation\EventSubscriber\SmartIpEventSubscriber::submitFormSettings()
  2. 8.3 modules/smart_ip_maxmind_geoip2_bin_db/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_maxmind_geoip2_bin_db\EventSubscriber\SmartIpEventSubscriber::submitFormSettings()
  3. 8.3 modules/smart_ip_ipinfodb_web_service/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_ipinfodb_web_service\EventSubscriber\SmartIpEventSubscriber::submitFormSettings()
  4. 8.3 modules/smart_ip_ip2location_bin_db/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_ip2location_bin_db\EventSubscriber\SmartIpEventSubscriber::submitFormSettings()
  5. 8.3 modules/smart_ip_abstract_web_service/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_abstract_web_service\EventSubscriber\SmartIpEventSubscriber::submitFormSettings()
  6. 8.3 modules/smart_ip_maxmind_geoip2_web_service/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_maxmind_geoip2_web_service\EventSubscriber\SmartIpEventSubscriber::submitFormSettings()
Same name and namespace in other branches
  1. 8.4 modules/device_geolocation/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\device_geolocation\EventSubscriber\SmartIpEventSubscriber::submitFormSettings()

Act on submission of main Smart IP admin settings form.

Parameters

\Drupal\smart_ip\AdminSettingsEvent $event: Smart IP admin settings override event for event listeners.

Overrides SmartIpDataSourceInterface::submitFormSettings

File

modules/device_geolocation/src/EventSubscriber/SmartIpEventSubscriber.php, line 116
Contains \Drupal\device_geolocation\EventSubscriber\SmartIpEventSubscriber.

Class

SmartIpEventSubscriber
Core functionality of this Smart IP data source module. Listens to Smart IP override events.

Namespace

Drupal\device_geolocation\EventSubscriber

Code

public function submitFormSettings(AdminSettingsEvent $event) {
  $config = \Drupal::configFactory()
    ->getEditable(self::configName());

  /** @var \Drupal\Core\Form\FormStateInterface $formState */
  $formState = $event
    ->getFormState();
  $frequencyCheck = $formState
    ->getValue('device_geolocation_frequency_check');
  if ($frequencyCheck == '') {
    $frequencyCheck = NULL;
  }
  else {

    // Convert from hours to seconds.
    $frequencyCheck = $frequencyCheck * 3600;
  }
  $config
    ->set('use_ajax_check', $formState
    ->getValue('device_geolocation_use_ajax_check'))
    ->set('frequency_check', $frequencyCheck)
    ->set('google_map_api_key', $formState
    ->getValue('device_geolocation_google_map_api_key'))
    ->set('google_map_region', $formState
    ->getValue('device_geolocation_google_map_region'))
    ->set('google_map_language', $formState
    ->getValue('device_geolocation_google_map_language'))
    ->save();
}