Refactor the insert tag replacer.

This commit is contained in:
David Molineus
2015-10-30 23:34:20 +01:00
parent 75cb767625
commit 374fe905a0
4 changed files with 133 additions and 97 deletions

View File

@@ -16,9 +16,11 @@ use Netzmacht\Contao\Leaflet\Event\GetJavascriptEvent;
use Netzmacht\Contao\Leaflet\Event\InitializeDefinitionMapperEvent;
use Netzmacht\Contao\Leaflet\Event\InitializeEventDispatcherEvent;
use Netzmacht\Contao\Leaflet\Event\InitializeLeafletBuilderEvent;
use Netzmacht\Contao\Leaflet\Frontend\InsertTag\LeafletInsertTagParser;
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\Contao\Leaflet\Mapper\Mapper;
use Netzmacht\Contao\Leaflet\Model\IconModel;
use Netzmacht\Contao\Toolkit\Event\InitializeSystemEvent;
use Netzmacht\LeafletPHP\Assets;
use Netzmacht\LeafletPHP\Definition\Type\ImageIcon;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -36,6 +38,7 @@ class BootSubscriber implements EventSubscriberInterface
public static function getSubscribedEvents()
{
return array(
InitializeSystemEvent::NAME => 'initializeInsertTagParser',
InitializeDefinitionMapperEvent::NAME => 'initializeDefinitionMapper',
InitializeEventDispatcherEvent::NAME => 'initializeEventDispatcher',
InitializeLeafletBuilderEvent::NAME => 'initializeLeafletBuilder',
@@ -43,6 +46,23 @@ class BootSubscriber implements EventSubscriberInterface
);
}
/**
* Initialize the leaflet insert tag parser.
*
* @param InitializeSystemEvent $event The event.
*
* @return void
*/
public function initializeInsertTagParser(InitializeSystemEvent $event)
{
$container = $event->getServiceContainer();
$debugMode = $container->getConfig()->get('debugMode');
$mapService = $container->getService('leaflet.map.service');
$parser = new LeafletInsertTagParser($mapService, $debugMode);
$container->getInsertTagReplacer()->registerParser($parser);
}
/**
* Create and register all configured mappers.
*