diff --git a/module/config/config.php b/module/config/config.php index cf03d4d..c9b58f3 100644 --- a/module/config/config.php +++ b/module/config/config.php @@ -88,7 +88,12 @@ $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\MapMapper'; // Layer mappers. $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\TileLayerMapper'; -$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\ProviderLayerMapper'; +$GLOBALS['LEAFLET_MAPPERS'][] = function () { + return new \Netzmacht\Contao\Leaflet\Mapper\Layer\ProviderLayerMapper( + $GLOBALS['LEAFLET_TILE_PROVIDERS'] + ); +}; + $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\MarkersLayerMapper'; $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\GroupLayerMapper'; $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Layer\VectorsLayerMapper'; diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ProviderLayerMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ProviderLayerMapper.php index ee45ed2..9652ff4 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ProviderLayerMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ProviderLayerMapper.php @@ -40,11 +40,11 @@ class ProviderLayerMapper extends AbstractLayerMapper /** * Construct. * - * @SuppressWarnings(PHPMD.Superglobals) + * @param array $providers Registered providers. */ - public function __construct() + public function __construct(array $providers) { - $this->providers = &$GLOBALS['LEAFLET_TILE_PROVIDERS']; + $this->providers = $providers; parent::__construct(); }