public function SmartIpEventSubscriber::formSettings in Smart IP 8.4
Same name in this branch
- 8.4 modules/device_geolocation/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\device_geolocation\EventSubscriber\SmartIpEventSubscriber::formSettings()
- 8.4 modules/smart_ip_maxmind_geoip2_bin_db/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_maxmind_geoip2_bin_db\EventSubscriber\SmartIpEventSubscriber::formSettings()
- 8.4 modules/smart_ip_ipinfodb_web_service/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_ipinfodb_web_service\EventSubscriber\SmartIpEventSubscriber::formSettings()
- 8.4 modules/smart_ip_ip2location_bin_db/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_ip2location_bin_db\EventSubscriber\SmartIpEventSubscriber::formSettings()
- 8.4 modules/smart_ip_abstract_web_service/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_abstract_web_service\EventSubscriber\SmartIpEventSubscriber::formSettings()
- 8.4 modules/smart_ip_maxmind_geoip2_web_service/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_maxmind_geoip2_web_service\EventSubscriber\SmartIpEventSubscriber::formSettings()
Same name and namespace in other branches
- 8.3 modules/device_geolocation/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\device_geolocation\EventSubscriber\SmartIpEventSubscriber::formSettings()
Add the form elements of this Smart IP data source to main admin settings page of Smart IP.
Parameters
\Drupal\smart_ip\AdminSettingsEvent $event: Smart IP admin settings override event for event listeners.
Overrides SmartIpDataSourceInterface::formSettings
File
- modules/
device_geolocation/ src/ EventSubscriber/ SmartIpEventSubscriber.php, line 42 - 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\EventSubscriberCode
public function formSettings(AdminSettingsEvent $event) {
$config = \Drupal::config(self::configName());
$form = $event
->getForm();
$form['device_geolocation_preferences'] = [
'#type' => 'fieldset',
'#title' => t('Device Geolocation settings'),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
];
$form['device_geolocation_preferences']['device_geolocation_use_ajax_check'] = [
'#type' => 'checkbox',
'#title' => t("Use AJAX in user's geolocation checking (useful if the site or pages \n listed above are cached)"),
'#default_value' => $config
->get('use_ajax_check'),
];
$frequencyCheck = $config
->get('frequency_check');
$form['device_geolocation_preferences']['device_geolocation_frequency_check'] = [
'#title' => t("Frequency of user's geolocation checking"),
'#type' => 'textfield',
'#size' => 10,
'#description' => t('Specify number of hours will prompt the user for geolocation. Leave it
empty to disable.'),
'#default_value' => $frequencyCheck === NULL ? '' : $frequencyCheck / 3600,
'#field_suffix' => t('hours'),
];
$form['device_geolocation_preferences']['device_geolocation_google_map_api_key'] = array(
'#title' => t('Google map API key'),
'#type' => 'textfield',
'#description' => t('The use of Google map service requires API key. Get your API key @here.', [
'@here' => Link::fromTextAndUrl(t('here'), Url::fromUri('https://developers.google.com/maps/documentation/javascript/get-api-key'))
->toString(),
]),
'#default_value' => $config
->get('google_map_api_key'),
);
$form['device_geolocation_preferences']['device_geolocation_google_map_region'] = [
'#type' => 'textfield',
'#title' => t('Google map region'),
'#default_value' => $config
->get('google_map_region'),
'#description' => t("Specify a region code, which alters the Google map service's behavior based \n on a given country or territory. See @google_localization_region", [
'@google_localization_region' => Link::fromTextAndUrl(t('Google Maps API - Localizing the Map (Region localization)'), Url::fromUri('https://developers.google.com/maps/documentation/javascript/localization#Region'))
->toString(),
]),
];
$form['device_geolocation_preferences']['device_geolocation_google_map_language'] = [
'#type' => 'textfield',
'#title' => t('Google map localization'),
'#default_value' => $config
->get('google_map_language'),
'#description' => t('Change the Google map service default language settings.
See @google_localization_language', [
'@google_localization_language' => Link::fromTextAndUrl(t('Google Maps API - Localizing the Map (Language localization)'), Url::fromUri('https://developers.google.com/maps/documentation/javascript/localization#Language'))
->toString(),
]),
];
$event
->setForm($form);
}