class Dummy in Geolocation Field 8.3
Same name and namespace in other branches
- 8 tests/modules/geolocation_dummy_geocoder/src/Plugin/geolocation/Geocoder/Dummy.php \Drupal\geolocation_dummy_geocoder\Plugin\geolocation\Geocoder\Dummy
- 8.2 tests/modules/geolocation_dummy_geocoder/src/Plugin/geolocation/Geocoder/Dummy.php \Drupal\geolocation_dummy_geocoder\Plugin\geolocation\Geocoder\Dummy
Provides the Google Geocoding API.
Plugin annotation
@Geocoder(
id = "dummy",
name = @Translation("Dummy Geocoder"),
locationCapable = true,
boundaryCapable = false,
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\geolocation\GeocoderBase implements ContainerFactoryPluginInterface, GeocoderInterface
- class \Drupal\geolocation_dummy_geocoder\Plugin\geolocation\Geocoder\Dummy
- class \Drupal\geolocation\GeocoderBase implements ContainerFactoryPluginInterface, GeocoderInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of Dummy
1 file declares its use of Dummy
- DummyGeocoderController.php in tests/
modules/ geolocation_dummy_geocoder/ src/ Controller/ DummyGeocoderController.php
File
- tests/
modules/ geolocation_dummy_geocoder/ src/ Plugin/ geolocation/ Geocoder/ Dummy.php, line 18
Namespace
Drupal\geolocation_dummy_geocoder\Plugin\geolocation\GeocoderView source
class Dummy extends GeocoderBase {
/**
* Test targets.
*
* @var array
*/
public static $targets = [
'Berlin' => [
'lat' => 52.517037,
'lng' => 13.38886,
],
'Vladivostok' => [
'lat' => 43.115284,
'lng' => 131.885401,
],
'Santiago de Chile' => [
'lat' => -33.437913,
'lng' => -70.65045600000001,
],
];
/**
* {@inheritdoc}
*/
public function formAttachGeocoder(array &$render_array, $element_name) {
$render_array['geolocation_geocoder_dummy'] = [
'#type' => 'textfield',
'#description' => $this
->t('Enter one of the statically defined targets. See geolocation/Geocoder/Dummy.php.'),
'#attributes' => [
'class' => [
'form-autocomplete',
'geolocation-geocoder-dummy',
],
'data-source-identifier' => $element_name,
],
];
$render_array = BubbleableMetadata::mergeAttachments($render_array, [
'#attached' => [
'library' => [
0 => 'geolocation_dummy_geocoder/geocoder',
],
],
]);
$render_array['geolocation_geocoder_dummy_state'] = [
'#type' => 'hidden',
'#default_value' => 1,
'#attributes' => [
'class' => [
'geolocation-geocoder-dummy-state',
],
'data-source-identifier' => $element_name,
],
];
}
/**
* {@inheritdoc}
*/
public function geocode($address) {
if (empty($address)) {
return FALSE;
}
if (!empty(self::$targets[$address])) {
return [
'location' => [
'lat' => self::$targets[$address]['lat'],
'lng' => self::$targets[$address]['lng'],
],
'boundary' => [
'lat_north_east' => self::$targets[$address]['lat'] + 0.01,
'lng_north_east' => self::$targets[$address]['lng'] + 0.01,
'lat_south_west' => self::$targets[$address]['lat'] + 0.01,
'lng_south_west' => self::$targets[$address]['lng'] + 0.01,
],
];
}
else {
return FALSE;
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
Dummy:: |
public static | property | Test targets. | |
Dummy:: |
public | function |
Attach geocoding logic to input element. Overrides GeocoderBase:: |
|
Dummy:: |
public | function |
Geocode an address. Overrides GeocoderBase:: |
|
GeocoderBase:: |
protected | property | Country formatter manager. | |
GeocoderBase:: |
protected | function | Get formatted address elements from atomics. | |
GeocoderBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
1 |
GeocoderBase:: |
protected | function | Return plugin default settings. | 2 |
GeocoderBase:: |
public | function |
Return additional options form. Overrides GeocoderInterface:: |
2 |
GeocoderBase:: |
public | function | Return plugin settings. | |
GeocoderBase:: |
public | function |
Process the form built above. Overrides GeocoderInterface:: |
|
GeocoderBase:: |
public | function |
Reverse geocode an address. Overrides GeocoderInterface:: |
3 |
GeocoderBase:: |
public | function |
GoogleGeocoderBase constructor. Overrides PluginBase:: |
1 |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |