You are here

public static function GeolocationMap::getLocations in Geolocation Field 8.3

Same name and namespace in other branches
  1. 8.2 src/Element/GeolocationMap.php \Drupal\geolocation\Element\GeolocationMap::getLocations()

Recursively return all locations in render array.

Parameters

array $render_array: Geolocation Map render array.

Return value

array Geolocation Map Locations.

1 call to GeolocationMap::getLocations()
GoogleStaticMaps::alterRenderArray in modules/geolocation_google_maps/modules/geolocation_google_static_maps/src/Plugin/geolocation/MapProvider/GoogleStaticMaps.php
Alter render array.

File

src/Element/GeolocationMap.php, line 210

Class

GeolocationMap
Provides a render element to display a geolocation map.

Namespace

Drupal\geolocation\Element

Code

public static function getLocations(array $render_array) {
  $locations = [];
  if (!empty($render_array['#type']) && $render_array['#type'] == 'geolocation_map_location') {
    $locations[] = $render_array;
  }
  elseif (!empty($render_array['#children'])) {
    foreach ($render_array['#children'] as $child) {
      if (is_array($child)) {
        $locations = array_merge($locations, static::getLocations($child));
      }
    }
  }
  else {
    foreach (Element::children($render_array) as $key) {
      if (is_array($render_array[$key])) {
        $locations = array_merge($locations, static::getLocations($render_array[$key]));
      }
    }
  }
  return $locations;
}