public function GoogleGeocoderBase::formAttachGeocoder in Geolocation Field 8.2
Same name and namespace in other branches
- 8.3 modules/geolocation_google_maps/src/GoogleGeocoderBase.php \Drupal\geolocation_google_maps\GoogleGeocoderBase::formAttachGeocoder()
Attach geocoding logic to input element.
Parameters
array $render_array: Form containing the input element.
string $element_name: Name of the input element.
Return value
array|null Updated form element or NULL.
Overrides GeocoderBase::formAttachGeocoder
2 calls to GoogleGeocoderBase::formAttachGeocoder()
- GoogleGeocodingAPI::formAttachGeocoder in modules/
geolocation_google_maps/ src/ Plugin/ geolocation/ Geocoder/ GoogleGeocodingAPI.php - Attach geocoding logic to input element.
- GooglePlacesAPI::formAttachGeocoder in modules/
geolocation_google_maps/ modules/ geolocation_google_places_api/ src/ Plugin/ geolocation/ Geocoder/ GooglePlacesAPI.php - Attach geocoding logic to input element.
2 methods override GoogleGeocoderBase::formAttachGeocoder()
- GoogleGeocodingAPI::formAttachGeocoder in modules/
geolocation_google_maps/ src/ Plugin/ geolocation/ Geocoder/ GoogleGeocodingAPI.php - Attach geocoding logic to input element.
- GooglePlacesAPI::formAttachGeocoder in modules/
geolocation_google_maps/ modules/ geolocation_google_places_api/ src/ Plugin/ geolocation/ Geocoder/ GooglePlacesAPI.php - Attach geocoding logic to input element.
File
- modules/
geolocation_google_maps/ src/ GoogleGeocoderBase.php, line 86
Class
- GoogleGeocoderBase
- Base class.
Namespace
Drupal\geolocation_google_mapsCode
public function formAttachGeocoder(array &$render_array, $element_name) {
parent::formAttachGeocoder($render_array, $element_name);
$render_array['#attached'] = BubbleableMetadata::mergeAttachments(empty($render_array['#attached']) ? [] : $render_array['#attached'], [
'library' => [
'geolocation_google_maps/googlemapsapi',
'geolocation_google_maps/google',
],
]);
if (!empty($this->configuration['component_restrictions'])) {
foreach ($this->configuration['component_restrictions'] as $component => $restriction) {
if (empty($restriction)) {
continue;
}
switch ($component) {
case 'administrative_area':
$component = 'administrativeArea';
break;
case 'postal_code':
$component = 'postalCode';
break;
}
$render_array['#attached'] = BubbleableMetadata::mergeAttachments(empty($render_array['#attached']) ? [] : $render_array['#attached'], [
'drupalSettings' => [
'geolocation' => [
'geocoder' => [
$this
->getPluginId() => [
'componentRestrictions' => [
$component => $restriction,
],
],
],
],
],
]);
}
}
if (!empty($this->configuration['boundary_restriction'])) {
$bounds = [];
foreach ($this->configuration['boundary_restriction'] as $key => $value) {
if (empty($value)) {
return;
}
$bounds[$key] = (double) $value;
}
if (!empty($bounds)) {
$render_array['#attached'] = BubbleableMetadata::mergeAttachments(empty($render_array['#attached']) ? [] : $render_array['#attached'], [
'drupalSettings' => [
'geolocation' => [
'geocoder' => [
$this
->getPluginId() => [
'bounds' => $bounds,
],
],
],
],
]);
}
}
}