You are here

public function LeafletService::leafletMapGetInfo in Leaflet 8

Same name and namespace in other branches
  1. 2.1.x src/LeafletService.php \Drupal\leaflet\LeafletService::leafletMapGetInfo()
  2. 2.0.x src/LeafletService.php \Drupal\leaflet\LeafletService::leafletMapGetInfo()

Get all available Leaflet map definitions.

Parameters

string $map: The specific map definition string.

Return value

array The leaflet maps definition array.

File

src/LeafletService.php, line 140

Class

LeafletService
Provides a LeafletService class.

Namespace

Drupal\leaflet

Code

public function leafletMapGetInfo($map = NULL) {
  static $drupal_static_fast;
  if (!isset($drupal_static_fast)) {
    $drupal_static_fast['leaflet_map_info'] =& drupal_static(__FUNCTION__);
  }
  $map_info =& $drupal_static_fast['leaflet_map_info'];
  if (empty($map_info)) {
    if ($cached = \Drupal::cache()
      ->get('leaflet_map_info')) {
      $map_info = $cached->data;
    }
    else {
      $map_info = $this->moduleHandler
        ->invokeAll('leaflet_map_info');

      // Let other modules alter the map info.
      $this->moduleHandler
        ->alter('leaflet_map_info', $map_info);
      \Drupal::cache()
        ->set('leaflet_map_info', $map_info);
    }
  }
  if (empty($map)) {
    return $map_info;
  }
  else {
    return isset($map_info[$map]) ? $map_info[$map] : [];
  }
}