mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-29 19:43:50 +01:00
Use assets as a service.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
use Netzmacht\Contao\Leaflet\Boot;
|
||||
use Netzmacht\Contao\Leaflet\ContaoAssets;
|
||||
use Netzmacht\Contao\Leaflet\Frontend\Helper\FrontendApi;
|
||||
use Netzmacht\Contao\Leaflet\Frontend\ValueFilter;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
@@ -38,10 +39,17 @@ $container['leaflet.map.service'] = $container->share(function ($container) {
|
||||
$container['leaflet.definition.mapper'],
|
||||
$container['leaflet.definition.builder'],
|
||||
$container['event-dispatcher'],
|
||||
$container['input']
|
||||
$container['input'],
|
||||
$container['leaflet.map.assets']
|
||||
);
|
||||
});
|
||||
|
||||
/*
|
||||
* Contao assets handler. Loads Leaflet assets as contao (static) assets.
|
||||
*/
|
||||
$container['leaflet.map.assets'] = $container->share(function () {
|
||||
return new ContaoAssets();
|
||||
});
|
||||
|
||||
/*
|
||||
* The leaflet boot.
|
||||
|
||||
@@ -59,6 +59,13 @@ class MapService
|
||||
*/
|
||||
private $input;
|
||||
|
||||
/**
|
||||
* Map assets collector.
|
||||
*
|
||||
* @var Assets
|
||||
*/
|
||||
private $assets;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
@@ -66,17 +73,20 @@ class MapService
|
||||
* @param Leaflet $leaflet The Leaflet instance.
|
||||
* @param EventDispatcher $eventDispatcher The Contao event dispatcher.
|
||||
* @param \Input $input Thw request input.
|
||||
* @param Assets $assets
|
||||
*/
|
||||
public function __construct(
|
||||
DefinitionMapper $mapper,
|
||||
Leaflet $leaflet,
|
||||
EventDispatcher $eventDispatcher,
|
||||
\Input $input
|
||||
\Input $input,
|
||||
Assets $assets
|
||||
) {
|
||||
$this->mapper = $mapper;
|
||||
$this->leaflet = $leaflet;
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
$this->input = $input;
|
||||
$this->assets = $assets;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,11 +157,10 @@ class MapService
|
||||
$style = ''
|
||||
) {
|
||||
$definition = $this->getDefinition($mapId, $filter, $elementId);
|
||||
$assets = new ContaoAssets();
|
||||
$template = \Controller::getTemplate($template);
|
||||
|
||||
// @codingStandardsIgnoreStart - Set for the template.
|
||||
$javascript = $this->leaflet->build($definition, $assets);
|
||||
$javascript = $this->leaflet->build($definition, $this->assets);
|
||||
$mapId = $definition->getId();
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
|
||||
Reference in New Issue
Block a user