Switch to PSR-4.

This commit is contained in:
David Molineus
2017-10-05 14:16:56 +02:00
parent e3344ffd4f
commit 827c746b0d
87 changed files with 4 additions and 6 deletions

View File

@@ -0,0 +1,37 @@
<?php
/**
* @package contao-leaflet-maps
* @author David Molineus <david.molineus@netzmacht.de>
* @copyright 2014-2016 netzmacht David Molineus
* @license LGPL 3.0
* @filesource
*
*/
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper;
/**
* Class AbstractControlMapper is the base mapper for the control model.
*
* @package Netzmacht\Contao\Leaflet\Mapper\Control
*/
class AbstractControlMapper extends AbstractTypeMapper
{
/**
* Class of the model being build.
*
* @var string
*/
protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\ControlModel';
/**
* {@inheritdoc}
*/
protected function initialize()
{
$this->optionsBuilder->addOption('position');
}
}

View File

@@ -0,0 +1,75 @@
<?php
/**
* @package contao-leaflet-maps
* @author David Molineus <david.molineus@netzmacht.de>
* @copyright 2014-2016 netzmacht David Molineus
* @license LGPL 3.0
* @filesource
*
*/
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
use Netzmacht\Contao\Leaflet\Filter\Filter;
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\LeafletPHP\Definition;
use Netzmacht\LeafletPHP\Definition\Control\Attribution;
use Netzmacht\LeafletPHP\Definition\Map;
/**
* AttributionControlMapper maps the the attribution database definition to the definition class.
*
* @package Netzmacht\Contao\Leaflet\Mapper\Control
*/
class AttributionControlMapper extends AbstractControlMapper
{
/**
* Class of the definition being created.
*
* @var string
*/
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Control\Attribution';
/**
* Layer type.
*
* @var string
*/
protected static $type = 'attribution';
/**
* {@inheritdoc}
*/
protected function initialize()
{
parent::initialize();
$this->optionsBuilder->addConditionalOption('prefix');
}
/**
* {@inheritdoc}
*/
protected function build(
Definition $definition,
\Model $model,
DefinitionMapper $mapper,
Filter $filter = null,
Definition $parent = null
) {
if (!$definition instanceof Attribution) {
return;
}
if ($model->disableDefault && $parent instanceof Map) {
$parent->setAttributionControl(false);
}
$attributions = deserialize($model->attributions, true);
foreach ($attributions as $attribution) {
$definition->addAttribution($attribution);
}
}
}

View File

@@ -0,0 +1,49 @@
<?php
/**
* @package contao-leaflet-maps
* @author David Molineus <david.molineus@netzmacht.de>
* @copyright 2014-2016 netzmacht David Molineus
* @license LGPL 3.0
* @filesource
*
*/
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
use Netzmacht\LeafletPHP\Definition;
/**
* Class FullscreenControlMapper.
*
* @package Netzmacht\Contao\Leaflet\Mapper\Control
*/
class FullscreenControlMapper extends AbstractControlMapper
{
/**
* Class of the definition being created.
*
* @var string
*/
protected static $definitionClass = 'Netzmacht\LeafletPHP\Plugins\FullScreen\FullScreenControl';
/**
* Layer type.
*
* @var string
*/
protected static $type = 'fullscreen';
/**
* {@inheritdoc}
*/
protected function initialize()
{
parent::initialize();
$this->optionsBuilder
->addOption('forceSeparateButton', 'separate')
->addConditionalOption('title', 'title', 'buttonTitle')
->addOption('forcePseudoFullScreen', 'simulateFullScreen');
}
}

View File

@@ -0,0 +1,65 @@
<?php
/**
* @package contao-leaflet-maps
* @author David Molineus <david.molineus@netzmacht.de>
* @copyright 2014-2016 netzmacht David Molineus
* @license LGPL 3.0
* @filesource
*
*/
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
use Netzmacht\Contao\Leaflet\Filter\Filter;
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\Contao\Leaflet\Model\ControlModel;
/**
* Class LayersControlMapper maps the control model to the layers control definition.
*
* @package Netzmacht\Contao\Leaflet\Mapper\Control
*/
class LayersControlMapper extends AbstractControlMapper
{
/**
* Class of the definition being created.
*
* @var string
*/
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Control\Layers';
/**
* Layer type.
*
* @var string
*/
protected static $type = 'layers';
/**
* {@inheritdoc}
*/
protected function buildConstructArguments(
\Model $model,
DefinitionMapper $mapper,
Filter $filter = null,
$elementId = null
) {
$arguments = parent::buildConstructArguments($model, $mapper, $filter, $elementId);
$arguments[1] = array();
$arguments[2] = array();
/** @var ControlModel $model */
$collection = $model->findActiveLayers();
if ($collection) {
foreach ($collection as $layer) {
$argument = ($layer->controlMode === 'overlay') ? 2 : 1;
$arguments[$argument][] = $mapper->handle($layer, $filter);
}
}
return $arguments;
}
}

View File

@@ -0,0 +1,97 @@
<?php
/**
* @package contao-leaflet-maps
* @author David Molineus <david.molineus@netzmacht.de>
* @copyright 2014-2016 netzmacht David Molineus
* @license LGPL 3.0
* @filesource
*
*/
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
use Netzmacht\Contao\Leaflet\Filter\Filter;
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\Contao\Leaflet\Model\ControlModel;
use Netzmacht\LeafletPHP\Definition;
use Netzmacht\LeafletPHP\Definition\Control\Zoom;
use Netzmacht\LeafletPHP\Plugins\Loading\LoadingControl;
use Netzmacht\LeafletPHP\Plugins\Loading\SpinJsLoadingControl;
/**
* Class LoadingControlMapper maps the control model to the loading control definition.
*
* @package Netzmacht\Contao\Leaflet\Mapper\Control
*/
class LoadingControlMapper extends AbstractControlMapper
{
/**
* Layer type.
*
* @var string
*/
protected static $type = 'loading';
/**
* {@inheritdoc}
*/
protected function getClassName(\Model $model, DefinitionMapper $mapper, Filter $filter = null)
{
if ($model->spinjs) {
return 'Netzmacht\LeafletPHP\Plugins\Loading\SpinJsLoadingControl';
}
return 'Netzmacht\LeafletPHP\Plugins\Loading\LoadingControl';
}
/**
* {@inheritdoc}
*/
protected function initialize()
{
parent::initialize();
$this->optionsBuilder->addOption('separate');
}
/**
* {@inheritdoc}
*/
protected function build(
Definition $definition,
\Model $model,
DefinitionMapper $mapper,
Filter $filter = null,
Definition $parent = null
) {
parent::build($definition, $model, $mapper, $filter);
if ($definition instanceof SpinJsLoadingControl && $model->spin) {
$config = json_decode($model->spin, true);
if (is_array($config)) {
$definition->setSpin($config);
}
}
if ($definition instanceof LoadingControl && !$definition->isSeparate() && $model->zoomControl) {
// Only assign if zoom control is activated and part of the map.
$control = ControlModel::findOneBy(
array('active=1', 'type=?', 'pid=?', 'id=?'),
array('zoom', $model->pid, $model->zoomControl)
);
if ($control) {
$control = $mapper->handle($control);
if ($control instanceof Zoom) {
// By default the loading control overrides the position of the zoom control. Deactivate it by
// overriding the position.
$definition->setPosition($control->getPosition());
$definition->setZoomControl($control);
}
}
}
}
}

View File

@@ -0,0 +1,44 @@
<?php
/**
* @package contao-leaflet-maps
* @author David Molineus <david.molineus@netzmacht.de>
* @copyright 2014-2016 netzmacht David Molineus
* @license LGPL 3.0
* @filesource
*
*/
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
/**
* Class ScaleControlMapper maps the database item of the type "scale" to the scale control.
*
* @package Netzmacht\Contao\Leaflet\Mapper\Control
*/
class ScaleControlMapper extends AbstractControlMapper
{
/**
* Class of the definition being created.
*
* @var string
*/
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Control\Scale';
/**
* Layer type.
*
* @var string
*/
protected static $type = 'scale';
/**
* {@inheritdoc}
*/
protected function initialize()
{
parent::initialize();
$this->optionsBuilder->addOptions('maxWidth', 'metric', 'imperial', 'updateWhenIdle');
}
}

View File

@@ -0,0 +1,48 @@
<?php
/**
* @package contao-leaflet-maps
* @author David Molineus <david.molineus@netzmacht.de>
* @copyright 2014-2016 netzmacht David Molineus
* @license LGPL 3.0
* @filesource
*
*/
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
/**
* Class ZoomControlMapper maps the zoom database definition to the zoom control.
*
* @package Netzmacht\Contao\Leaflet\Mapper\Control
*/
class ZoomControlMapper extends AbstractControlMapper
{
/**
* Class of the definition being created.
*
* @var string
*/
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Control\Zoom';
/**
* Layer type.
*
* @var string
*/
protected static $type = 'zoom';
/**
* {@inheritdoc}
*/
protected function initialize()
{
parent::initialize();
$this->optionsBuilder
->addConditionalOption('zoomInText')
->addConditionalOption('zoomOutText')
->addConditionalOption('zoomInTitle')
->addConditionalOption('zoomOutTitle');
}
}