Refactor boot subscriber.

This commit is contained in:
David Molineus
2016-10-06 08:53:23 +02:00
parent 2c9dd0ad48
commit b1cfbb3b04
4 changed files with 96 additions and 55 deletions

View File

@@ -104,39 +104,39 @@ $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\Loading
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\FullscreenControlMapper';
// Vector mappers.
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Interop\Container\ContainerInterface $container) {
$GLOBALS['LEAFLET_MAPPERS'][] = function () {
return new Netzmacht\Contao\Leaflet\Mapper\Vector\PolylineMapper(
$container->get(\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER)
$GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER]
);
};
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Interop\Container\ContainerInterface $container) {
$GLOBALS['LEAFLET_MAPPERS'][] = function () {
return new Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolylineMapper(
$container->get(\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER)
$GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER]
);
};
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Interop\Container\ContainerInterface $container) {
$GLOBALS['LEAFLET_MAPPERS'][] = function () {
return new Netzmacht\Contao\Leaflet\Mapper\Vector\PolygonMapper(
$container->get(\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER)
$GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER]
);
};
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Interop\Container\ContainerInterface $container) {
$GLOBALS['LEAFLET_MAPPERS'][] = function () {
return new Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolygonMapper(
$container->get(\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER)
$GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER]
);
};
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Interop\Container\ContainerInterface $container) {
$GLOBALS['LEAFLET_MAPPERS'][] = function () {
return new Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMapper(
$container->get(\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER)
$GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER]
);
};
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Interop\Container\ContainerInterface $container) {
$GLOBALS['LEAFLET_MAPPERS'][] = function () {
return new Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMarkerMapper(
$container->get(\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER)
$GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER]
);
};
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Interop\Container\ContainerInterface $container) {
$GLOBALS['LEAFLET_MAPPERS'][] = function () {
return new Netzmacht\Contao\Leaflet\Mapper\Vector\RectangleMapper(
$container->get(\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER)
$GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER]
);
};
@@ -145,9 +145,9 @@ $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\UI\PopupMapper'
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Type\ImageIconMapper';
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Type\DivIconMapper';
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Style\FixedStyleMapper';
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Interop\Container\ContainerInterface $container) {
$GLOBALS['LEAFLET_MAPPERS'][] = function () {
return new \Netzmacht\Contao\Leaflet\Mapper\UI\MarkerMapper(
$container->get(\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER)
$GLOBALS['container'][\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER]
);
};

View File

@@ -9,7 +9,7 @@
*
*/
return array(
'Netzmacht\Contao\Leaflet\Subscriber\BootSubscriber',
$GLOBALS['container']['leaflet.boot.subscriber'],
'Netzmacht\Contao\Leaflet\Subscriber\HashSubscriber',
'Netzmacht\Contao\Leaflet\Subscriber\GeoJsonSubscriber',
);

View File

@@ -23,6 +23,7 @@ use Netzmacht\Contao\Leaflet\Frontend\MapModule;
use Netzmacht\Contao\Leaflet\Frontend\ValueFilter;
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\Contao\Leaflet\MapProvider;
use Netzmacht\Contao\Leaflet\Subscriber\BootSubscriber;
use Netzmacht\Contao\Toolkit\Data\Alias\Filter\ExistingAliasFilter;
use Netzmacht\Contao\Toolkit\Data\Alias\Filter\SlugifyFilter;
use Netzmacht\Contao\Toolkit\Data\Alias\Filter\SuffixFilter;
@@ -69,6 +70,15 @@ $container[LeafletServices::BOOT] = $container->share(function ($container) {
return new Boot($container[Services::EVENT_DISPATCHER]);
});
$container['leaflet.boot.subscriber'] = $container->share(function ($container) {
return new BootSubscriber(
$container[Services::ASSETS_MANAGER],
$GLOBALS['LEAFLET_MAPPERS'],
$GLOBALS['LEAFLET_ENCODERS'],
$GLOBALS['LEAFLET_LIBRARIES']
);
});
/*
* The definition mapper.