You are here

public function Yandex::alterRenderArray in Geolocation Field 8.2

Same name and namespace in other branches
  1. 8.3 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 111

Class

Yandex
Provides Yandex Maps API.

Namespace

Drupal\geolocation_yandex\Plugin\geolocation\MapProvider

Code

public function alterRenderArray(array $render_array, array $map_settings, array $context = []) {
  $map_settings = $this
    ->getSettings($map_settings);
  $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,
            ],
          ],
        ],
      ],
    ],
  ]);
  $render_array = parent::alterRenderArray($render_array, $map_settings, $context);
  return $render_array;
}