Use options callback to get supported layers and providers.

This commit is contained in:
David Molineus
2017-10-09 14:01:22 +02:00
parent 96c78d4306
commit ac87bcf947
2 changed files with 22 additions and 2 deletions

View File

@@ -112,6 +112,26 @@ class LayerDcaListener extends AbstractListener
$this->labelRenderer = $labelRenderer; $this->labelRenderer = $labelRenderer;
} }
/**
* Get layer options.
*
* @return array
*/
public function getLayerOptions(): array
{
return array_keys($this->layers);
}
/**
* Get tile provider options.
*
* @return array
*/
public function getProviderOptions(): array
{
return array_keys($this->tileProviders);
}
/** /**
* Get variants of the tile provider. * Get variants of the tile provider.
* *

View File

@@ -286,7 +286,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = [
'chosen' => true, 'chosen' => true,
'helpwizard' => true, 'helpwizard' => true,
], ],
'options' => array_keys($GLOBALS['LEAFLET_LAYERS']), 'options_callback' => ['netzmacht.contao_leaflet_maps.listeners.dca.layer', 'getLayerOptions'],
'reference' => &$GLOBALS['TL_LANG']['leaflet_layer'], 'reference' => &$GLOBALS['TL_LANG']['leaflet_layer'],
'sql' => "varchar(32) NOT NULL default ''", 'sql' => "varchar(32) NOT NULL default ''",
], ],
@@ -312,7 +312,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = [
'submitOnChange' => true, 'submitOnChange' => true,
'chosen' => true, 'chosen' => true,
], ],
'options' => array_keys($GLOBALS['LEAFLET_TILE_PROVIDERS']), 'options_callback' => ['netzmacht.contao_leaflet_maps.listeners.dca.layer', 'getProviderOptions'],
'sql' => "varchar(32) NOT NULL default ''", 'sql' => "varchar(32) NOT NULL default ''",
], ],
'tile_provider_variant' => [ 'tile_provider_variant' => [