Dependency injection for the map provider.

This commit is contained in:
David Molineus
2016-10-06 09:09:11 +02:00
parent ee4c157e9c
commit 025ce1ba81
2 changed files with 25 additions and 8 deletions

View File

@@ -53,7 +53,9 @@ $container[LeafletServices::MAP_PROVIDER] = $container->share(function ($contain
$container[LeafletServices::DEFINITION_BUILDER],
$container[Services::EVENT_DISPATCHER],
$container[Services::INPUT],
$container[LeafletServices::MAP_ASSETS]
$container[LeafletServices::MAP_ASSETS],
$GLOBALS['LEAFLET_FILTERS'],
\Config::get('debugMode') || \Config::get('displayErrors')
);
});

View File

@@ -66,6 +66,20 @@ class MapProvider
*/
private $assets;
/**
* Request filters configuration.
*
* @var array
*/
private $filters;
/**
* Display errors setting.
*
* @var bool
*/
private $displayErrors;
/**
* Construct.
*
@@ -74,19 +88,25 @@ class MapProvider
* @param EventDispatcher $eventDispatcher The Contao event dispatcher.
* @param \Input $input Thw request input.
* @param Assets $assets Assets handler.
* @param array $filters Request filters configuration.
* @param bool $displayErrors Display errors setting.
*/
public function __construct(
DefinitionMapper $mapper,
Leaflet $leaflet,
EventDispatcher $eventDispatcher,
\Input $input,
Assets $assets
Assets $assets,
array $filters,
$displayErrors
) {
$this->mapper = $mapper;
$this->leaflet = $leaflet;
$this->eventDispatcher = $eventDispatcher;
$this->input = $input;
$this->assets = $assets;
$this->filters = $filters;
$this->displayErrors = $displayErrors;
}
/**
@@ -233,12 +253,7 @@ class MapProvider
return;
}
$controller = new DataController(
$this,
$GLOBALS['LEAFLET_FILTERS'],
\Config::get('debugMode') || \Config::get('displayErrors')
);
$controller = new DataController($this, $this->filters, $this->displayErrors);
$controller->execute($data);
if ($exit) {