mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-12-01 12:33:45 +01:00
Switch to PSR-4.
This commit is contained in:
75
src/Mapper/Control/AttributionControlMapper.php
Normal file
75
src/Mapper/Control/AttributionControlMapper.php
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user