Rename MapService to MapProvider

This commit is contained in:
David Molineus
2016-10-05 14:18:15 +02:00
parent c8ea8d4fab
commit abcc4f5d88
6 changed files with 42 additions and 42 deletions

View File

@@ -17,7 +17,7 @@ use Netzmacht\Contao\Leaflet\Frontend\MapElement;
use Netzmacht\Contao\Leaflet\Frontend\MapModule; 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\MapProvider;
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;
@@ -38,10 +38,10 @@ use Symfony\Component\EventDispatcher\EventDispatcher;
global $container; global $container;
/* /*
* Leaflet map service is a simply api entry to to get the leaflet map from the database. * Leaflet map provider is a simply api entry to to get the leaflet map from the database.
*/ */
$container['leaflet.map.service'] = $container->share(function ($container) { $container['leaflet.map.provider'] = $container->share(function ($container) {
return new MapService( return new MapProvider(
$container['leaflet.definition.mapper'], $container['leaflet.definition.mapper'],
$container['leaflet.definition.builder'], $container['leaflet.definition.builder'],
$container['event-dispatcher'], $container['event-dispatcher'],
@@ -183,7 +183,7 @@ $container[Services::CONTENT_ELEMENTS_MAP]['leaflet'] = function ($model, $colum
$model, $model,
$container->get(Services::TEMPLATE_FACTORY), $container->get(Services::TEMPLATE_FACTORY),
$container->get(Services::TRANSLATOR), $container->get(Services::TRANSLATOR),
$container->get('leaflet.map.service'), $container->get('leaflet.map.provider'),
$container->get(Services::INPUT), $container->get(Services::INPUT),
$container->get(Services::CONFIG), $container->get(Services::CONFIG),
$column $column
@@ -195,7 +195,7 @@ $container[Services::MODULES_MAP]['leaflet'] = function ($model, $column, Contai
$model, $model,
$container->get(Services::TEMPLATE_FACTORY), $container->get(Services::TEMPLATE_FACTORY),
$container->get(Services::TRANSLATOR), $container->get(Services::TRANSLATOR),
$container->get('leaflet.map.service'), $container->get('leaflet.map.provider'),
$container->get(Services::INPUT), $container->get(Services::INPUT),
$container->get(Services::CONFIG), $container->get(Services::CONFIG),
$column $column

View File

@@ -14,7 +14,7 @@ namespace Netzmacht\Contao\Leaflet\Frontend;
use ContaoCommunityAlliance\Translator\TranslatorInterface as Translator; use ContaoCommunityAlliance\Translator\TranslatorInterface as Translator;
use Database\Result; use Database\Result;
use Model\Collection; use Model\Collection;
use Netzmacht\Contao\Leaflet\MapService; use Netzmacht\Contao\Leaflet\MapProvider;
use Netzmacht\Contao\Leaflet\Model\MapModel; use Netzmacht\Contao\Leaflet\Model\MapModel;
use Netzmacht\Contao\Toolkit\Component\Hybrid\AbstractHybrid; use Netzmacht\Contao\Toolkit\Component\Hybrid\AbstractHybrid;
use Netzmacht\Contao\Toolkit\View\Template\TemplateFactory; use Netzmacht\Contao\Toolkit\View\Template\TemplateFactory;
@@ -27,11 +27,11 @@ use Netzmacht\Contao\Toolkit\View\Template\TemplateFactory;
abstract class AbstractMapHybrid extends AbstractHybrid abstract class AbstractMapHybrid extends AbstractHybrid
{ {
/** /**
* The map service. * The map provider.
* *
* @var MapService * @var MapProvider
*/ */
private $mapService; private $mapProvider;
/** /**
* The user input. * The user input.
@@ -53,7 +53,7 @@ abstract class AbstractMapHybrid extends AbstractHybrid
* @param Result|\Model|Collection $model Component model. * @param Result|\Model|Collection $model Component model.
* @param TemplateFactory $templateFactory Template factory. * @param TemplateFactory $templateFactory Template factory.
* @param Translator $translator Translator. * @param Translator $translator Translator.
* @param MapService $mapService Map service. * @param MapProvider $mapProvider Map provider.
* @param \Input $input Input * @param \Input $input Input
* @param \Config $config Config. * @param \Config $config Config.
* @param string $column Column in which the element appears. * @param string $column Column in which the element appears.
@@ -62,16 +62,16 @@ abstract class AbstractMapHybrid extends AbstractHybrid
$model, $model,
TemplateFactory $templateFactory, TemplateFactory $templateFactory,
Translator $translator, Translator $translator,
MapService $mapService, MapProvider $mapProvider,
\Input $input, \Input $input,
\Config $config, \Config $config,
$column = null $column = null
) { ) {
parent::__construct($model, $templateFactory, $translator, $column); parent::__construct($model, $templateFactory, $translator, $column);
$this->mapService = $mapService; $this->mapProvider = $mapProvider;
$this->input = $input; $this->input = $input;
$this->config = $config; $this->config = $config;
} }
/** /**
@@ -81,7 +81,7 @@ abstract class AbstractMapHybrid extends AbstractHybrid
*/ */
public function generate() public function generate()
{ {
$this->mapService->handleAjaxRequest($this->getIdentifier()); $this->mapProvider->handleAjaxRequest($this->getIdentifier());
if (TL_MODE === 'BE') { if (TL_MODE === 'BE') {
$model = MapModel::findByPk($this->get('leaflet_map')); $model = MapModel::findByPk($this->get('leaflet_map'));
@@ -118,7 +118,7 @@ abstract class AbstractMapHybrid extends AbstractHybrid
try { try {
$template = $this->get('leaflet_template') ?: 'leaflet_map_js'; $template = $this->get('leaflet_template') ?: 'leaflet_map_js';
$mapId = $this->getIdentifier(); $mapId = $this->getIdentifier();
$map = $this->mapService->generate($this->get('leaflet_map'), null, $mapId, $template); $map = $this->mapProvider->generate($this->get('leaflet_map'), null, $mapId, $template);
$GLOBALS['TL_BODY'][] = '<script>' . $map .'</script>'; $GLOBALS['TL_BODY'][] = '<script>' . $map .'</script>';

View File

@@ -12,7 +12,7 @@
namespace Netzmacht\Contao\Leaflet\Frontend; namespace Netzmacht\Contao\Leaflet\Frontend;
use Netzmacht\Contao\Leaflet\Filter\Filter; use Netzmacht\Contao\Leaflet\Filter\Filter;
use Netzmacht\Contao\Leaflet\MapService; use Netzmacht\Contao\Leaflet\MapProvider;
/** /**
* The data controller handles ajax request for sub data. * The data controller handles ajax request for sub data.
@@ -22,11 +22,11 @@ use Netzmacht\Contao\Leaflet\MapService;
class DataController class DataController
{ {
/** /**
* The map service. * The map provider.
* *
* @var MapService * @var MapProvider
*/ */
private $mapService; private $mapProvider;
/** /**
* The user input data. * The user input data.
@@ -44,13 +44,13 @@ class DataController
/** /**
* Construct. * Construct.
* *
* @param MapService $mapService The map service. * @param MapProvider $mapProvider The map provider.
* @param array $input The user input as array. * @param array $input The user input as array.
*/ */
public function __construct(MapService $mapService, $input) public function __construct(MapProvider $mapProvider, $input)
{ {
$this->mapService = $mapService; $this->mapProvider = $mapProvider;
$this->input = array_merge($this->input, $input); $this->input = array_merge($this->input, $input);
} }
/** /**
@@ -120,7 +120,7 @@ class DataController
switch ($type) { switch ($type) {
case 'layer': case 'layer':
$data = $this->mapService->getFeatureCollection($dataId, $filter); $data = $this->mapProvider->getFeatureCollection($dataId, $filter);
break; break;
default: default:

View File

@@ -11,7 +11,7 @@
namespace Netzmacht\Contao\Leaflet\Frontend\InsertTag; namespace Netzmacht\Contao\Leaflet\Frontend\InsertTag;
use Netzmacht\Contao\Leaflet\MapService; use Netzmacht\Contao\Leaflet\MapProvider;
use Netzmacht\Contao\Toolkit\InsertTag\Parser; use Netzmacht\Contao\Toolkit\InsertTag\Parser;
/** /**
@@ -31,9 +31,9 @@ class LeafletInsertTagParser implements Parser
/** /**
* The map service. * The map service.
* *
* @var MapService * @var MapProvider
*/ */
private $mapService; private $mapProvider;
/** /**
* Debug mode. * Debug mode.
@@ -45,13 +45,13 @@ class LeafletInsertTagParser implements Parser
/** /**
* LeafletInsertTagParser constructor. * LeafletInsertTagParser constructor.
* *
* @param MapService $mapService Map service. * @param MapProvider $mapProvider Map provider.
* @param bool $debugMode Debug mode. * @param bool $debugMode Debug mode.
*/ */
public function __construct(MapService $mapService, $debugMode) public function __construct(MapProvider $mapProvider, $debugMode)
{ {
$this->mapService = $mapService; $this->mapProvider = $mapProvider;
$this->debugMode = $debugMode; $this->debugMode = $debugMode;
} }
/** /**
@@ -101,7 +101,7 @@ class LeafletInsertTagParser implements Parser
private function generateMap($mapId, $template, $style) private function generateMap($mapId, $template, $style)
{ {
try { try {
return $this->mapService->generate($mapId, null, $mapId, $template, $style); return $this->mapProvider->generate($mapId, null, $mapId, $template, $style);
} catch (\Exception $e) { } catch (\Exception $e) {
if ($this->debugMode) { if ($this->debugMode) {
throw $e; throw $e;

View File

@@ -25,11 +25,11 @@ use Netzmacht\LeafletPHP\Leaflet;
use Symfony\Component\EventDispatcher\EventDispatcherInterface as EventDispatcher; use Symfony\Component\EventDispatcher\EventDispatcherInterface as EventDispatcher;
/** /**
* Class MapService. * Class MapProvider.
* *
* @package Netzmacht\Contao\Leaflet * @package Netzmacht\Contao\Leaflet
*/ */
class MapService class MapProvider
{ {
/** /**
* The definition mapper. * The definition mapper.

View File

@@ -56,10 +56,10 @@ class BootSubscriber implements EventSubscriberInterface
*/ */
public function initializeInsertTagParser(InitializeSystemEvent $event) public function initializeInsertTagParser(InitializeSystemEvent $event)
{ {
$container = $event->getContainer(); $container = $event->getContainer();
$debugMode = $container->get(Services::CONFIG)->get('debugMode'); $debugMode = $container->get(Services::CONFIG)->get('debugMode');
$mapService = $container->get('leaflet.map.service'); $mapProvider = $container->get('leaflet.map.provider');
$parser = new LeafletInsertTagParser($mapService, $debugMode); $parser = new LeafletInsertTagParser($mapProvider, $debugMode);
$container->get(Services::INSERT_TAG_REPLACER)->registerParser($parser); $container->get(Services::INSERT_TAG_REPLACER)->registerParser($parser);
} }