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