You are here

function yamaps_library_info_alter in Yandex.Maps 8

Implements hook_library_info_alter().

File

./yamaps.module, line 59
Yandex Maps module main file.

Code

function yamaps_library_info_alter(&$libraries, $extension) {

  // Update yandex map API url
  if (isset($libraries['yandex-map-api'])) {
    $key = \Drupal::config('yamaps.settings')
      ->get('yamaps_api_key');
    if (!empty($key)) {
      $oldDescription = $libraries['yandex-map-api']['js'];
      $url = key($oldDescription);
      $params = array_values($oldDescription);
      $url .= '&apikey=' . $key;
      $libraries['yandex-map-api']['js'] = [
        $url => $params,
      ];
    }
  }
}