Use dependency injection for the provider layer mapper.

This commit is contained in:
David Molineus
2016-10-06 09:04:51 +02:00
parent daf902b989
commit ee4c157e9c
2 changed files with 9 additions and 4 deletions

View File

@@ -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';

View File

@@ -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();
}