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\ValueFilter;
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\SlugifyFilter;
use Netzmacht\Contao\Toolkit\Data\Alias\Filter\SuffixFilter;
@@ -38,10 +38,10 @@ use Symfony\Component\EventDispatcher\EventDispatcher;
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) {
return new MapService(
$container['leaflet.map.provider'] = $container->share(function ($container) {
return new MapProvider(
$container['leaflet.definition.mapper'],
$container['leaflet.definition.builder'],
$container['event-dispatcher'],
@@ -183,7 +183,7 @@ $container[Services::CONTENT_ELEMENTS_MAP]['leaflet'] = function ($model, $colum
$model,
$container->get(Services::TEMPLATE_FACTORY),
$container->get(Services::TRANSLATOR),
$container->get('leaflet.map.service'),
$container->get('leaflet.map.provider'),
$container->get(Services::INPUT),
$container->get(Services::CONFIG),
$column
@@ -195,7 +195,7 @@ $container[Services::MODULES_MAP]['leaflet'] = function ($model, $column, Contai
$model,
$container->get(Services::TEMPLATE_FACTORY),
$container->get(Services::TRANSLATOR),
$container->get('leaflet.map.service'),
$container->get('leaflet.map.provider'),
$container->get(Services::INPUT),
$container->get(Services::CONFIG),
$column

View File

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

View File

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

View File

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

View File

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

View File

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