2015-01-05 12:25:46 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @package dev
|
|
|
|
|
* @author David Molineus <david.molineus@netzmacht.de>
|
|
|
|
|
* @copyright 2015 netzmacht creative David Molineus
|
|
|
|
|
* @license LGPL 3.0
|
|
|
|
|
* @filesource
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
|
|
|
|
|
|
2015-01-24 21:37:25 +01:00
|
|
|
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
2015-01-05 14:58:37 +01:00
|
|
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
2015-01-09 22:33:57 +01:00
|
|
|
use Netzmacht\Contao\Leaflet\Model\ControlModel;
|
2015-01-05 14:58:37 +01:00
|
|
|
|
2015-01-12 19:03:29 +01:00
|
|
|
/**
|
|
|
|
|
* Class LayersControlMapper maps the control model to the layers control definition.
|
|
|
|
|
*
|
|
|
|
|
* @package Netzmacht\Contao\Leaflet\Mapper\Control
|
|
|
|
|
*/
|
2015-01-05 12:25:46 +01:00
|
|
|
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';
|
2015-01-05 14:58:37 +01:00
|
|
|
|
2015-01-09 13:41:09 +01:00
|
|
|
/**
|
|
|
|
|
* {@inheritdoc}
|
|
|
|
|
*/
|
|
|
|
|
protected function buildConstructArguments(
|
|
|
|
|
\Model $model,
|
|
|
|
|
DefinitionMapper $mapper,
|
2015-01-24 21:37:25 +01:00
|
|
|
Filter $filter = null,
|
2015-01-09 13:41:09 +01:00
|
|
|
$elementId = null
|
|
|
|
|
) {
|
2015-01-24 21:37:25 +01:00
|
|
|
$arguments = parent::buildConstructArguments($model, $mapper, $filter, $elementId);
|
2015-01-05 14:58:37 +01:00
|
|
|
$arguments[1] = array();
|
|
|
|
|
$arguments[2] = array();
|
|
|
|
|
|
2015-01-09 22:33:57 +01:00
|
|
|
/** @var ControlModel $model */
|
2015-01-09 23:48:25 +01:00
|
|
|
$collection = $model->findActiveLayers();
|
2015-01-05 14:58:37 +01:00
|
|
|
|
|
|
|
|
if ($collection) {
|
|
|
|
|
foreach ($collection as $layer) {
|
2015-01-09 22:33:57 +01:00
|
|
|
$argument = ($layer->controlMode === 'overlay') ? 2 : 1;
|
2015-01-05 14:58:37 +01:00
|
|
|
|
2015-01-24 21:37:25 +01:00
|
|
|
$arguments[$argument][] = $mapper->handle($layer, $filter);
|
2015-01-05 14:58:37 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $arguments;
|
|
|
|
|
}
|
2015-01-05 12:25:46 +01:00
|
|
|
}
|