Make the data controller a service.

This commit is contained in:
David Molineus
2017-10-11 15:42:49 +02:00
parent 6bfaf63d4f
commit 56a68175fe
3 changed files with 36 additions and 49 deletions

View File

@@ -17,7 +17,6 @@ use Doctrine\Common\Cache\Cache;
use Netzmacht\Contao\Leaflet\Encoder\ContaoAssets;
use Netzmacht\Contao\Leaflet\Event\GetJavascriptEvent;
use Netzmacht\Contao\Leaflet\Filter\Filter;
use Netzmacht\Contao\Leaflet\Filter\FilterFactory;
use Netzmacht\Contao\Leaflet\Frontend\DataController;
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\Contao\Leaflet\Model\LayerModel;
@@ -70,20 +69,6 @@ class MapProvider
*/
private $assets;
/**
* Filter factory.
*
* @var FilterFactory
*/
private $filterFactory;
/**
* Display errors setting.
*
* @var bool
*/
private $displayErrors;
/**
* Cache.
*
@@ -91,6 +76,13 @@ class MapProvider
*/
private $cache;
/**
* Data controller.
*
* @var DataController
*/
private $dataController;
/**
* Construct.
*
@@ -100,8 +92,9 @@ class MapProvider
* @param Input $input Thw request input.
* @param ContaoAssets $assets Assets handler.
* @param Cache $cache Cache.
* @param FilterFactory $filterFactory Filter factory.
* @param bool $displayErrors Display errors setting.
* @param DataController $dataController Data controller.
*
* @internal param FilterFactory $filterFactory Filter factory.
*/
public function __construct(
DefinitionMapper $mapper,
@@ -110,17 +103,15 @@ class MapProvider
$input,
ContaoAssets $assets,
Cache $cache,
FilterFactory $filterFactory,
$displayErrors
DataController $dataController
) {
$this->mapper = $mapper;
$this->leaflet = $leaflet;
$this->eventDispatcher = $eventDispatcher;
$this->input = $input;
$this->assets = $assets;
$this->filterFactory = $filterFactory;
$this->displayErrors = $displayErrors;
$this->cache = $cache;
$this->dataController = $dataController;
}
/**
@@ -295,8 +286,7 @@ class MapProvider
return;
}
$controller = new DataController($this, $this->filterFactory, $this->displayErrors);
$controller->execute($data);
$this->dataController->execute($data, $this);
if ($exit) {
exit;