forked from Snck3rs/contao-leaflet-maps
Introduce service names constants.
This commit is contained in:
@@ -10,9 +10,12 @@
|
||||
*/
|
||||
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Netzmacht\Contao\Leaflet\Alias\UnderscoreFilter;
|
||||
use Netzmacht\Contao\Leaflet\Boot;
|
||||
use Netzmacht\Contao\Leaflet\ContaoAssets;
|
||||
use Netzmacht\Contao\Leaflet\Dca\ControlCallbacks;
|
||||
use Netzmacht\Contao\Leaflet\Dca\LayerCallbacks;
|
||||
use Netzmacht\Contao\Leaflet\Dca\MapCallbacks;
|
||||
use Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices;
|
||||
use Netzmacht\Contao\Leaflet\Frontend\MapElement;
|
||||
use Netzmacht\Contao\Leaflet\Frontend\MapModule;
|
||||
use Netzmacht\Contao\Leaflet\Frontend\ValueFilter;
|
||||
@@ -40,38 +43,38 @@ global $container;
|
||||
/*
|
||||
* Leaflet map provider is a simply api entry to to get the leaflet map from the database.
|
||||
*/
|
||||
$container['leaflet.map.provider'] = $container->share(function ($container) {
|
||||
$container[LeafletServices::MAP_PROVIDER] = $container->share(function ($container) {
|
||||
return new MapProvider(
|
||||
$container['leaflet.definition.mapper'],
|
||||
$container['leaflet.definition.builder'],
|
||||
$container['event-dispatcher'],
|
||||
$container['input'],
|
||||
$container['leaflet.map.assets']
|
||||
$container[LeafletServices::DEFINITION_MAPPER],
|
||||
$container[LeafletServices::DEFINITION_BUILDER],
|
||||
$container[Services::EVENT_DISPATCHER],
|
||||
$container[Services::INPUT],
|
||||
$container[LeafletServices::MAP_ASSETS]
|
||||
);
|
||||
});
|
||||
|
||||
/*
|
||||
* Contao assets handler. Loads Leaflet assets as contao (static) assets.
|
||||
*/
|
||||
$container['leaflet.map.assets'] = $container->share(function () {
|
||||
$container[LeafletServices::MAP_ASSETS] = $container->share(function () {
|
||||
return new ContaoAssets();
|
||||
});
|
||||
|
||||
/*
|
||||
* The leaflet boot.
|
||||
*/
|
||||
$container['leaflet.boot'] = $container->share(function ($container) {
|
||||
return new Boot($container['event-dispatcher']);
|
||||
$container[LeafletServices::BOOT] = $container->share(function ($container) {
|
||||
return new Boot($container[Services::EVENT_DISPATCHER]);
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
* The definition mapper.
|
||||
*/
|
||||
$container['leaflet.definition.mapper'] = $container->share(function ($container) {
|
||||
$container[LeafletServices::DEFINITION_MAPPER] = $container->share(function ($container) {
|
||||
/** @var Boot $boot */
|
||||
$boot = $container['leaflet.boot'];
|
||||
$mapper = new DefinitionMapper($container['event-dispatcher']);
|
||||
$boot = $container[LeafletServices::BOOT];
|
||||
$mapper = new DefinitionMapper($container[Services::EVENT_DISPATCHER]);
|
||||
|
||||
return $boot->initializeDefinitionMapper($mapper);
|
||||
});
|
||||
@@ -80,9 +83,9 @@ $container['leaflet.definition.mapper'] = $container->share(function ($container
|
||||
/*
|
||||
* The local event dispatcher is used for the leaflet javascript encoding system.
|
||||
*/
|
||||
$container['leaflet.definition.builder.event-dispatcher'] = $container->share(function ($container) {
|
||||
$container[LeafletServices::DEFINITION_BUILDER_EVENT_DISPATCHER] = $container->share(function ($container) {
|
||||
/** @var Boot $boot */
|
||||
$boot = $container['leaflet.boot'];
|
||||
$boot = $container[LeafletServices::BOOT];
|
||||
$dispatcher = new EventDispatcher();
|
||||
|
||||
return $boot->initializeEventDispatcher($dispatcher);
|
||||
@@ -91,8 +94,8 @@ $container['leaflet.definition.builder.event-dispatcher'] = $container->share(fu
|
||||
/*
|
||||
* The javascript encoder factory being used for building the map javascript.
|
||||
*/
|
||||
$container['leaflet.definition.builder.encoder-factory'] = function ($container) {
|
||||
$dispatcher = $container['leaflet.definition.builder.event-dispatcher'];
|
||||
$container[LeafletServices::DEFINITION_ENCODER_FACTORY] = function ($container) {
|
||||
$dispatcher = $container[LeafletServices::DEFINITION_BUILDER_EVENT_DISPATCHER];
|
||||
|
||||
return function (Output $output) use ($dispatcher) {
|
||||
$encoder = new ChainEncoder();
|
||||
@@ -108,11 +111,11 @@ $container['leaflet.definition.builder.encoder-factory'] = function ($container)
|
||||
/*
|
||||
* The leaflet builder transforms the definition to javascript.
|
||||
*/
|
||||
$container['leaflet.definition.builder'] = $container->share(function($container) {
|
||||
$container[LeafletServices::DEFINITION_BUILDER] = $container->share(function($container) {
|
||||
/** @var Boot $boot */
|
||||
$boot = $container['leaflet.boot'];
|
||||
$dispatcher = $container['leaflet.definition.builder.event-dispatcher'];
|
||||
$factory = $container['leaflet.definition.builder.encoder-factory'];
|
||||
$boot = $container[LeafletServices::BOOT];
|
||||
$dispatcher = $container[LeafletServices::DEFINITION_BUILDER_EVENT_DISPATCHER];
|
||||
$factory = $container[LeafletServices::DEFINITION_ENCODER_FACTORY];
|
||||
|
||||
$builder = new Builder($factory);
|
||||
$leaflet = new Leaflet($builder, $dispatcher, array(), JSON_UNESCAPED_SLASHES ^ Flags::BUILD_STACK);
|
||||
@@ -120,7 +123,7 @@ $container['leaflet.definition.builder'] = $container->share(function($container
|
||||
return $boot->initializeLeafletBuilder($leaflet);
|
||||
});
|
||||
|
||||
$container['leaflet.frontend.value-filter'] = $container->share(function($container) {
|
||||
$container[LeafletServices::FRONTEND_VALUE_FILTER] = $container->share(function($container) {
|
||||
return new ValueFilter($container[Services::INSERT_TAG_REPLACER]);
|
||||
});
|
||||
|
||||
@@ -129,7 +132,7 @@ $container['leaflet.frontend.value-filter'] = $container->share(function($contai
|
||||
*
|
||||
* @return \Netzmacht\Contao\Toolkit\Data\Alias\AliasGenerator
|
||||
*/
|
||||
$container['leaflet.alias-generator'] = $container->share(
|
||||
$container[LeafletServices::ALIAS_GENERATOR] = $container->share(
|
||||
function ($container) {
|
||||
return function ($dataContainerName, $aliasField, $fields) use ($container) {
|
||||
$filters = [
|
||||
@@ -149,18 +152,28 @@ $container['leaflet.alias-generator'] = $container->share(
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Callback helper class for tl_leaflet_map.
|
||||
*
|
||||
* @return MapCallbacks
|
||||
*/
|
||||
$container['leaflet.dca.map-callbacks'] = $container->share(
|
||||
function ($container) {
|
||||
return new \Netzmacht\Contao\Leaflet\Dca\MapCallbacks(
|
||||
return new MapCallbacks(
|
||||
$container[Services::DCA_MANAGER],
|
||||
$container[Services::DATABASE_CONNECTION]
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Callback helper class for tl_leaflet_layer.
|
||||
*
|
||||
* @return LayerCallbacks
|
||||
*/
|
||||
$container['leaflet.dca.layer-callbacks'] = $container->share(
|
||||
function ($container) {
|
||||
return new \Netzmacht\Contao\Leaflet\Dca\LayerCallbacks(
|
||||
return new LayerCallbacks(
|
||||
$container[Services::DCA_MANAGER],
|
||||
$container[Services::DATABASE_CONNECTION],
|
||||
$GLOBALS['LEAFLET_LAYERS']
|
||||
@@ -168,33 +181,56 @@ $container['leaflet.dca.layer-callbacks'] = $container->share(
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Callback helper class for tl_leaflet_control.
|
||||
*
|
||||
* @return ControlCallbacks
|
||||
*/
|
||||
$container['leaflet.dca.control-callbacks'] = $container->share(
|
||||
function ($container) {
|
||||
return new \Netzmacht\Contao\Leaflet\Dca\ControlCallbacks(
|
||||
return new ControlCallbacks(
|
||||
$container[Services::DCA_MANAGER],
|
||||
$container[Services::DATABASE_CONNECTION]
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Component factory for content element.
|
||||
*
|
||||
* @param ContentModel $model Content model.
|
||||
* @param string $column Template section.
|
||||
* @param ContainerInterface $container Container.
|
||||
*
|
||||
* @return MapElement
|
||||
*/
|
||||
$container[Services::CONTENT_ELEMENTS_MAP]['leaflet'] = function ($model, $column, ContainerInterface $container) {
|
||||
return new MapElement(
|
||||
$model,
|
||||
$container->get(Services::TEMPLATE_FACTORY),
|
||||
$container->get(Services::TRANSLATOR),
|
||||
$container->get('leaflet.map.provider'),
|
||||
$container->get(LeafletServices::MAP_PROVIDER),
|
||||
$container->get(Services::INPUT),
|
||||
$container->get(Services::CONFIG),
|
||||
$column
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Component factory for frontend module.
|
||||
*
|
||||
* @param ModuleModel $model Module model.
|
||||
* @param string $column Template section.
|
||||
* @param ContainerInterface $container Container.
|
||||
*
|
||||
* @return MapModule
|
||||
*/
|
||||
$container[Services::MODULES_MAP]['leaflet'] = function ($model, $column, ContainerInterface $container) {
|
||||
return new MapModule(
|
||||
$model,
|
||||
$container->get(Services::TEMPLATE_FACTORY),
|
||||
$container->get(Services::TRANSLATOR),
|
||||
$container->get('leaflet.map.provider'),
|
||||
$container->get(LeafletServices::MAP_PROVIDER),
|
||||
$container->get(Services::INPUT),
|
||||
$container->get(Services::CONFIG),
|
||||
$column
|
||||
|
||||
Reference in New Issue
Block a user