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_abstract_web_service/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_abstract_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_abstract_web_service/ src/ EventSubscriber/ SmartIpEventSubscriber.php, line 83 - Contains \Drupal\smart_ip_abstract_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_abstract_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 @abstract web service. You will need a unique API key to use this and\n you must @register an Abstract account and @login to get and view your\n @api.", [
'@abstract' => Link::fromTextAndUrl(t('Abstract IP Geolocation'), Url::fromUri('https://www.abstractapi.com/ip-geolocation-api'))
->toString(),
'@register' => Link::fromTextAndUrl(t('register'), Url::fromUri('https://app.abstractapi.com/users/signup'))
->toString(),
'@login' => Link::fromTextAndUrl(t('logged in'), Url::fromUri('https://app.abstractapi.com/users/login'))
->toString(),
'@api' => Link::fromTextAndUrl(t('unique API'), Url::fromUri('https://app.abstractapi.com/api/ip-geolocation/tester'))
->toString(),
]);
$form['smart_ip_data_source_selection']['abstract_api_version'] = [
'#type' => 'select',
'#title' => t('Abstract IP Geolocation web service version'),
'#default_value' => $config
->get('version'),
'#options' => [
1 => 1,
],
'#description' => t('Select an Abstract IP Geolocation web service version.'),
'#states' => [
'visible' => [
':input[name="smart_ip_data_source"]' => [
'value' => self::sourceId(),
],
],
],
];
$form['smart_ip_data_source_selection']['abstract_api_key'] = [
'#type' => 'textfield',
'#title' => t('Abstract IP Geolocation web service API key'),
'#description' => t('The use of Abstract IP Geolocation web service requires API key. Registration for the
new API key is free, sign up @here.', [
'@here' => Link::fromTextAndUrl(t('here'), Url::fromUri('https://app.abstractapi.com/users/signup'))
->toString(),
]),
'#default_value' => $config
->get('api_key'),
'#states' => [
'visible' => [
':input[name="smart_ip_data_source"]' => [
'value' => self::sourceId(),
],
],
],
];
$event
->setForm($form);
}