Skip to content

Instantly share code, notes, and snippets.

@perifer
Forked from hugowetterberg/gist:206045
Created December 30, 2009 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perifer/265950 to your computer and use it in GitHub Desktop.
Save perifer/265950 to your computer and use it in GitHub Desktop.
<?php
/**
* Returns all the layers in the tile service.
*
* @return array
*/
function simplegeo_tileservice_get_layers() {
static $layers;
$cache_key = 'simplegeo_tileservice:layers';
if (!$layers && ($cache = cache_get($cache_key)) && isset($cache->data)) {
$layers = $cache->data;
}
if (!$layers) {
$layers = module_invoke_all('simplegeo_tileservice_layers');
drupal_alter('simplegeo_tileservice_layers', $layers);
// Get rid of layers with invalid types
$types = simplegeo_tileservice_get_layer_types();
foreach ($layers as $name => $def) {
if (!isset($def['type']) || !isset($types[$def['type']])) {
unset($types[$name]);
}
}
cache_set($cache_key, $layers);
}
return $layers;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment