Introduce service names constants.

This commit is contained in:
David Molineus
2016-10-05 15:30:55 +02:00
parent 436cf88901
commit 971f905ad2
11 changed files with 138 additions and 38 deletions

View File

@@ -10,7 +10,14 @@
namespace Netzmacht\Contao\Leaflet\DependencyInjection;
use Netzmacht\Contao\Leaflet\Boot;
use Netzmacht\Contao\Leaflet\Frontend\ValueFilter;
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\Contao\Leaflet\MapProvider;
use Netzmacht\Contao\Toolkit\Data\Alias\AliasGenerator;
use Netzmacht\LeafletPHP\Assets;
use Netzmacht\LeafletPHP\Leaflet;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* Class LeafletServices describes services provided by the leaflet package.
@@ -19,6 +26,62 @@ use Netzmacht\Contao\Leaflet\Frontend\ValueFilter;
*/
class LeafletServices
{
/**
* Service name for the alias generator which creates valid js aliases.
*
* @return AliasGenerator
*/
const ALIAS_GENERATOR = 'leaflet.alias-generator';
/**
* Service name of the boot handler.
*
* @return Boot
*/
const BOOT = 'leaflet.boot';
/**
* Service name of the definition builder.
*
* @return Leaflet
*/
const DEFINITION_BUILDER = 'leaflet.definition.builder';
/**
* Service name of the encoder factory used inside of the definition builder.
*
* @return \callable
*/
const DEFINITION_ENCODER_FACTORY = 'leaflet.definition.builder.encoder-factory';
/**
* Service name of the internal used event dispatcher of the definition builder.
*
* @return EventDispatcherInterface
*/
const DEFINITION_BUILDER_EVENT_DISPATCHER = 'leaflet.definition.builder.event-dispatcher';
/**
* Service name of the definition mapper.
*
* @return DefinitionMapper
*/
const DEFINITION_MAPPER = 'leaflet.definition.mapper';
/**
* Service name of the leaflet map provider.
*
* @return MapProvider
*/
const MAP_PROVIDER = 'leaflet.map.provider';
/**
* Service name of the map assets handler.
*
* @return Assets
*/
const MAP_ASSETS = 'leaflet.map.assets';
/**
* Service name of the frontend value filter.
*

View File

@@ -12,6 +12,7 @@
namespace Netzmacht\Contao\Leaflet\Subscriber;
use ContaoCommunityAlliance\Contao\EventDispatcher\EventDispatcherInitializer;
use Netzmacht\Contao\Leaflet\DependencyInjection\LeafletServices;
use Netzmacht\Contao\Leaflet\Event\GetJavascriptEvent;
use Netzmacht\Contao\Leaflet\Event\InitializeDefinitionMapperEvent;
use Netzmacht\Contao\Leaflet\Event\InitializeEventDispatcherEvent;
@@ -58,7 +59,7 @@ class BootSubscriber implements EventSubscriberInterface
{
$container = $event->getContainer();
$debugMode = $container->get(Services::CONFIG)->get('debugMode');
$mapProvider = $container->get('leaflet.map.provider');
$mapProvider = $container->get(LeafletServices::MAP_PROVIDER);
$parser = new LeafletInsertTagParser($mapProvider, $debugMode);
$container->get(Services::INSERT_TAG_REPLACER)->registerParser($parser);
@@ -154,7 +155,7 @@ class BootSubscriber implements EventSubscriberInterface
if ($collection) {
/** @var DefinitionMapper $mapper */
$mapper = $GLOBALS['container']['leaflet.definition.mapper'];
$mapper = $GLOBALS['container'][LeafletServices::DEFINITION_MAPPER];
$buffer = '';
$icons = array();