You are here

function leaflet_geojson_source_get_info in Leaflet GeoJSON 8

Same name and namespace in other branches
  1. 7.2 leaflet_geojson.module \leaflet_geojson_source_get_info()
  2. 7 leaflet_geojson.module \leaflet_geojson_source_get_info()

Retrieves the leaflet layer configuration.

3 calls to leaflet_geojson_source_get_info()
LeafletGeojson::blockForm in src/Plugin/Block/LeafletGeojson.php
LeafletGeojson::leafletGeojsonMapPaneRenderJavascriptSettings in src/Plugin/Block/LeafletGeojson.php
Helper function to generate the javascript settings.
LeafletGeojson::leafletGeojsonMapPaneRenderLayeredMap in src/Plugin/Block/LeafletGeojson.php
Helper function to generate the map markup based on the pane config.

File

./leaflet_geojson.module, line 31
API Extension for using Leaflet with GeoJSON.

Code

function leaflet_geojson_source_get_info($source = NULL, $skip_cache = FALSE) {
  $language = \Drupal::languageManager()
    ->getCurrentLanguage();
  $lang = $language
    ->getId();
  if (!$skip_cache) {
    static $drupal_static_fast;
    if (!isset($drupal_static_fast)) {
      $drupal_static_fast['leaflet_geojson_source_info'] =& drupal_static(__FUNCTION__);
    }
    $source_info =& $drupal_static_fast['leaflet_geojson_source_info'];
    if (!isset($source_info[$lang])) {
      if ($cache = \Drupal::cache()
        ->get("leaflet_geojson_source_info")) {
        $source_info = $cache->data;
      }
    }
  }
  if (empty($source_info[$lang])) {
    $options = array(
      'language' => $language,
    );
    $source_info_lang = Drupal::moduleHandler()
      ->invokeAll('leaflet_geojson_source_info', $options);

    // Let other modules alter the source info.
    Drupal::moduleHandler()
      ->alter('leaflet_geojson_source_info', $source_info_lang);
    $source_info[$lang] = $source_info_lang;
    \Drupal::cache()
      ->set("leaflet_geojson_source_info", $source_info);
  }
  if (empty($source)) {
    return $source_info[$lang];
  }
  elseif (isset($source_info[$lang][$source])) {
    return $source_info[$lang][$source];
  }
}