mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-29 11:33:46 +01:00
Refactor the factories so that they don't use the container.
This commit is contained in:
@@ -14,9 +14,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Frontend\Module;
|
||||
|
||||
use Contao\Config;
|
||||
use Contao\CoreBundle\Framework\Adapter;
|
||||
use Contao\Input;
|
||||
use Netzmacht\Contao\Leaflet\MapProvider;
|
||||
use Netzmacht\Contao\Toolkit\Component\Component;
|
||||
use Netzmacht\Contao\Toolkit\Component\ComponentFactory;
|
||||
use Psr\Container\ContainerInterface as Container;
|
||||
use Symfony\Component\Templating\EngineInterface as TemplateEngine;
|
||||
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
||||
|
||||
/**
|
||||
* Class MapElementFactory
|
||||
@@ -26,20 +31,61 @@ use Psr\Container\ContainerInterface as Container;
|
||||
class MapModuleFactory implements ComponentFactory
|
||||
{
|
||||
/**
|
||||
* Dependency container.
|
||||
* Template engine.
|
||||
*
|
||||
* @var Container
|
||||
* @var TemplateEngine
|
||||
*/
|
||||
private $container;
|
||||
private $templating;
|
||||
|
||||
/**
|
||||
* MapModuleFactory constructor.
|
||||
* Translator.
|
||||
*
|
||||
* @param Container $container Dependency container.
|
||||
* @var Translator
|
||||
*/
|
||||
public function __construct(Container $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
private $translator;
|
||||
|
||||
/**
|
||||
* Map provider.
|
||||
*
|
||||
* @var MapProvider
|
||||
*/
|
||||
private $mapProvider;
|
||||
|
||||
/**
|
||||
* Input adapter.
|
||||
*
|
||||
* @var Input|Adapter
|
||||
*/
|
||||
private $input;
|
||||
|
||||
/**
|
||||
* Config adapter.
|
||||
*
|
||||
* @var Config|Adapter
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* MapElementFactory constructor.
|
||||
*
|
||||
* @param TemplateEngine $engine Template engine.
|
||||
* @param Translator $translator Translator.
|
||||
* @param MapProvider $mapProvider Map provider.
|
||||
* @param Input|Adapter $input Input adapter.
|
||||
* @param Config|Adapter $config Config adapter.
|
||||
*/
|
||||
public function __construct(
|
||||
TemplateEngine $engine,
|
||||
Translator $translator,
|
||||
MapProvider $mapProvider,
|
||||
$input,
|
||||
$config
|
||||
) {
|
||||
$this->templating = $engine;
|
||||
$this->translator = $translator;
|
||||
$this->mapProvider = $mapProvider;
|
||||
$this->input = $input;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,11 +103,11 @@ class MapModuleFactory implements ComponentFactory
|
||||
{
|
||||
return new MapModule(
|
||||
$model,
|
||||
$this->container->get('templating'),
|
||||
$this->container->get('translator'),
|
||||
$this->container->get('netzmacht.contao_leaflet.map.provider'),
|
||||
$this->container->get('netzmacht.contao_toolkit.contao.input_adapter'),
|
||||
$this->container->get('netzmacht.contao_toolkit.contao.config_adapter'),
|
||||
$this->templating,
|
||||
$this->translator,
|
||||
$this->mapProvider,
|
||||
$this->input,
|
||||
$this->config,
|
||||
$column
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user