public function SmartIpEventSubscriber::formSettings in Smart IP 8.3
Same name in this branch
- 8.3 modules/device_geolocation/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\device_geolocation\EventSubscriber\SmartIpEventSubscriber::formSettings()
- 8.3 modules/smart_ip_maxmind_geoip2_bin_db/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_maxmind_geoip2_bin_db\EventSubscriber\SmartIpEventSubscriber::formSettings()
- 8.3 modules/smart_ip_ipinfodb_web_service/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_ipinfodb_web_service\EventSubscriber\SmartIpEventSubscriber::formSettings()
- 8.3 modules/smart_ip_ip2location_bin_db/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_ip2location_bin_db\EventSubscriber\SmartIpEventSubscriber::formSettings()
- 8.3 modules/smart_ip_abstract_web_service/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_abstract_web_service\EventSubscriber\SmartIpEventSubscriber::formSettings()
- 8.3 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.4 modules/smart_ip_ipinfodb_web_service/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_ipinfodb_web_service\EventSubscriber\SmartIpEventSubscriber::formSettings()
- 8.2 modules/smart_ip_ipinfodb_web_service/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_ipinfodb_web_service\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/
smart_ip_ipinfodb_web_service/ src/ EventSubscriber/ SmartIpEventSubscriber.php, line 122 - Contains \Drupal\smart_ip_ipinfodb_web_service\EventSubscriber\SmartIpEventSubscriber.
Class
- SmartIpEventSubscriber
- Core functionalty of this Smart IP data source module. Listens to Smart IP override events.
Namespace
Drupal\smart_ip_ipinfodb_web_service\EventSubscriberCode
public function formSettings(AdminSettingsEvent $event) {
$config = \Drupal::config(self::configName());
$form = $event
->getForm();
$form['smart_ip_data_source_selection']['smart_ip_data_source']['#options'][self::sourceId()] = t("Use @ipinfodb web service. The @ip2location free version database is used \n by @ipinfodb in their web service. You will need an API key to use this \n and you must be @login to get it. Note: if @ipinfodb respond too slow to \n geolocation request, your site's performance will be affected specially if \n Smart IP is configured to geolocate anonymous users.", [
'@ipinfodb' => Link::fromTextAndUrl(t('IPInfoDB.com'), Url::fromUri('http://www.ipinfodb.com'))
->toString(),
'@ip2location' => Link::fromTextAndUrl(t('IP2Location'), Url::fromUri('http://www.ip2location.com'))
->toString(),
'@login' => Link::fromTextAndUrl(t('logged in'), Url::fromUri('http://ipinfodb.com/login.php'))
->toString(),
]);
$form['smart_ip_data_source_selection']['ipinfodb_api_version'] = [
'#type' => 'select',
'#title' => t('IPInfoDB API version'),
'#default_value' => $config
->get('version'),
'#options' => [
2 => 2,
3 => 3,
],
'#description' => t('IPInfoDB.com version 2 do have region code, in version 3 it was removed.'),
'#states' => [
'visible' => [
':input[name="smart_ip_data_source"]' => [
'value' => self::sourceId(),
],
],
],
];
$form['smart_ip_data_source_selection']['ipinfodb_api_key'] = [
'#type' => 'textfield',
'#title' => t('IPInfoDB API key'),
'#description' => t('The use of IPInfoDB.com service requires API key. Registration for the
new API key is free, sign up @here.', [
'@here' => Link::fromTextAndUrl(t('here'), Url::fromUri('http://www.ipinfodb.com/register.php'))
->toString(),
]),
'#default_value' => $config
->get('api_key'),
'#states' => [
'visible' => [
':input[name="smart_ip_data_source"]' => [
'value' => self::sourceId(),
],
],
],
];
$event
->setForm($form);
}