forked from Snck3rs/contao-leaflet-maps
Drop the service container class.
This commit is contained in:
@@ -104,26 +104,40 @@ $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\Loading
|
|||||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\FullscreenControlMapper';
|
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\FullscreenControlMapper';
|
||||||
|
|
||||||
// Vector mappers.
|
// Vector mappers.
|
||||||
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Netzmacht\Contao\Leaflet\ServiceContainer $container) {
|
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Interop\Container\ContainerInterface $container) {
|
||||||
return new Netzmacht\Contao\Leaflet\Mapper\Vector\PolylineMapper($container->getFrontendValueFilter());
|
return new Netzmacht\Contao\Leaflet\Mapper\Vector\PolylineMapper(
|
||||||
|
$container->get(\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Netzmacht\Contao\Leaflet\ServiceContainer $container) {
|
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Interop\Container\ContainerInterface $container) {
|
||||||
return new Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolylineMapper($container->getFrontendValueFilter());
|
return new Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolylineMapper(
|
||||||
|
$container->get(\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Netzmacht\Contao\Leaflet\ServiceContainer $container) {
|
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Interop\Container\ContainerInterface $container) {
|
||||||
return new Netzmacht\Contao\Leaflet\Mapper\Vector\PolygonMapper($container->getFrontendValueFilter());
|
return new Netzmacht\Contao\Leaflet\Mapper\Vector\PolygonMapper(
|
||||||
|
$container->get(\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Netzmacht\Contao\Leaflet\ServiceContainer $container) {
|
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Interop\Container\ContainerInterface $container) {
|
||||||
return new Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolygonMapper($container->getFrontendValueFilter());
|
return new Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolygonMapper(
|
||||||
|
$container->get(\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Netzmacht\Contao\Leaflet\ServiceContainer $container) {
|
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Interop\Container\ContainerInterface $container) {
|
||||||
return new Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMapper($container->getFrontendValueFilter());
|
return new Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMapper(
|
||||||
|
$container->get(\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Netzmacht\Contao\Leaflet\ServiceContainer $container) {
|
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Interop\Container\ContainerInterface $container) {
|
||||||
return new Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMarkerMapper($container->getFrontendValueFilter());
|
return new Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMarkerMapper(
|
||||||
|
$container->get(\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Netzmacht\Contao\Leaflet\ServiceContainer $container) {
|
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Interop\Container\ContainerInterface $container) {
|
||||||
return new Netzmacht\Contao\Leaflet\Mapper\Vector\RectangleMapper($container->getFrontendValueFilter());
|
return new Netzmacht\Contao\Leaflet\Mapper\Vector\RectangleMapper(
|
||||||
|
$container->get(\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Miscellaneous mappers.
|
// Miscellaneous mappers.
|
||||||
@@ -131,8 +145,10 @@ $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\ImageIconMapper';
|
||||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Type\DivIconMapper';
|
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Type\DivIconMapper';
|
||||||
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Style\FixedStyleMapper';
|
$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Style\FixedStyleMapper';
|
||||||
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Netzmacht\Contao\Leaflet\ServiceContainer $container) {
|
$GLOBALS['LEAFLET_MAPPERS'][] = function (\Interop\Container\ContainerInterface $container) {
|
||||||
return new \Netzmacht\Contao\Leaflet\Mapper\UI\MarkerMapper($container->getFrontendValueFilter());
|
return new \Netzmacht\Contao\Leaflet\Mapper\UI\MarkerMapper(
|
||||||
|
$container->get(\Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices::FRONTEND_VALUE_FILTER)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ use Netzmacht\Contao\Leaflet\Frontend\MapModule;
|
|||||||
use Netzmacht\Contao\Leaflet\Frontend\ValueFilter;
|
use Netzmacht\Contao\Leaflet\Frontend\ValueFilter;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\MapService;
|
use Netzmacht\Contao\Leaflet\MapService;
|
||||||
use Netzmacht\Contao\Leaflet\ServiceContainer;
|
|
||||||
use Netzmacht\Contao\Toolkit\Data\Alias\Filter\ExistingAliasFilter;
|
use Netzmacht\Contao\Toolkit\Data\Alias\Filter\ExistingAliasFilter;
|
||||||
use Netzmacht\Contao\Toolkit\Data\Alias\Filter\SlugifyFilter;
|
use Netzmacht\Contao\Toolkit\Data\Alias\Filter\SlugifyFilter;
|
||||||
use Netzmacht\Contao\Toolkit\Data\Alias\Filter\SuffixFilter;
|
use Netzmacht\Contao\Toolkit\Data\Alias\Filter\SuffixFilter;
|
||||||
@@ -125,11 +124,6 @@ $container['leaflet.frontend.value-filter'] = $container->share(function($contai
|
|||||||
return new ValueFilter($container[Services::INSERT_TAG_REPLACER]);
|
return new ValueFilter($container[Services::INSERT_TAG_REPLACER]);
|
||||||
});
|
});
|
||||||
|
|
||||||
$container['leaflet.service-container'] = $container->share(function($container) {
|
|
||||||
return new ServiceContainer($container);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Leaflet alias generator.
|
* Leaflet alias generator.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @package netzmacht
|
||||||
|
* @author David Molineus <david.molineus@netzmacht.de>
|
||||||
|
* @copyright 2016 netzmacht David Molineus. All rights reserved.
|
||||||
|
* @filesource
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Netzmacht\Contao\Leaflet\DependencyInjection;
|
||||||
|
|
||||||
|
use Netzmacht\Contao\Leaflet\Frontend\ValueFilter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class LeafletServices describes services provided by the leaflet package.
|
||||||
|
*
|
||||||
|
* @package Netzmacht\Contao\Leaflet\DependencyInjection
|
||||||
|
*/
|
||||||
|
class LeafletServices
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Service name of the frontend value filter.
|
||||||
|
*
|
||||||
|
* @return ValueFilter
|
||||||
|
*/
|
||||||
|
const FRONTEND_VALUE_FILTER = 'leaflet.frontend.value-filter';
|
||||||
|
}
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package dev
|
|
||||||
* @author David Molineus <david.molineus@netzmacht.de>
|
|
||||||
* @copyright 2015 netzmacht creative David Molineus
|
|
||||||
* @license LGPL 3.0
|
|
||||||
* @filesource
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet;
|
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Frontend\ValueFilter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class ServiceContainer provides the services which are available for Contao leaflet.
|
|
||||||
*
|
|
||||||
* @package Netzmacht\Contao\Leaflet
|
|
||||||
*/
|
|
||||||
class ServiceContainer
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The global service container.
|
|
||||||
*
|
|
||||||
* @var \Pimple
|
|
||||||
*/
|
|
||||||
private $container;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct.
|
|
||||||
*
|
|
||||||
* @param \Pimple $container The global service container.
|
|
||||||
*/
|
|
||||||
public function __construct(\Pimple $container)
|
|
||||||
{
|
|
||||||
$this->container = $container;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the value filter service.
|
|
||||||
*
|
|
||||||
* @return ValueFilter
|
|
||||||
*/
|
|
||||||
public function getFrontendValueFilter()
|
|
||||||
{
|
|
||||||
return $this->getService('leaflet.frontend.value-filter');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a service from the container.
|
|
||||||
*
|
|
||||||
* @param string $name The service name.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getService($name)
|
|
||||||
{
|
|
||||||
return $this->container[$name];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -209,7 +209,7 @@ class BootSubscriber implements EventSubscriberInterface
|
|||||||
private function createMapper($mapper)
|
private function createMapper($mapper)
|
||||||
{
|
{
|
||||||
if (is_callable($mapper)) {
|
if (is_callable($mapper)) {
|
||||||
$container = $GLOBALS['container']['leaflet.service-container'];
|
$container = $GLOBALS['container'][Services::CONTAINER];
|
||||||
|
|
||||||
return $mapper($container);
|
return $mapper($container);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user