public function Yandex::alterRenderArray in Geolocation Field 8.3
Same name and namespace in other branches
- 8.2 modules/geolocation_yandex/src/Plugin/geolocation/MapProvider/Yandex.php \Drupal\geolocation_yandex\Plugin\geolocation\MapProvider\Yandex::alterRenderArray()
Alter render array.
Parameters
array $render_array: Render array.
array $map_settings: The current map settings.
array $context: Context like field formatter, field widget or view.
Return value
array Render attachments.
Overrides MapProviderBase::alterRenderArray
File
- modules/
geolocation_yandex/ src/ Plugin/ geolocation/ MapProvider/ Yandex.php, line 118
Class
- Yandex
- Provides Yandex Maps API.
Namespace
Drupal\geolocation_yandex\Plugin\geolocation\MapProviderCode
public function alterRenderArray(array $render_array, array $map_settings, array $context = []) {
$yandex_url_parts = parse_url(self::$apiBaseUrl);
$render_array['#attached'] = BubbleableMetadata::mergeAttachments(empty($render_array['#attached']) ? [] : $render_array['#attached'], [
'library' => [
'geolocation_yandex/geolocation.yandex',
],
'drupalSettings' => [
'geolocation' => [
'maps' => [
$render_array['#id'] => [
'settings' => [
'yandex_settings' => $map_settings,
],
],
],
],
],
// Add 'preconnect' resource hint.
'html_head' => [
[
[
'#tag' => 'link',
'#attributes' => [
'rel' => 'preconnect',
'href' => $yandex_url_parts['scheme'] . "://" . $yandex_url_parts['host'],
],
],
'geolocation_yandex_link_preconnect_map',
],
],
]);
return parent::alterRenderArray($render_array, $map_settings, $context);
}