* @copyright 2016-2017 netzmacht David Molineus. All rights reserved. * @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE * @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; } /** * {@inheritDoc} */ protected function initialize() { parent::initialize(); $this->optionsBuilder->addOptions(['collapsed', 'autoZIndex']); } }