Files
contao-leaflet-maps/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ReferenceLayerMapper.php

49 lines
1.2 KiB
PHP
Raw Normal View History

2015-01-09 15:24:34 +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\Layer;
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\Contao\Leaflet\Model\LayerModel;
2015-01-20 16:38:23 +01:00
use Netzmacht\LeafletPHP\Definition;
2015-01-09 15:24:34 +01:00
use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds;
/**
2015-01-12 19:03:29 +01:00
* Class ReferenceLayerMapper maps an reference layer to another layer.
2015-01-09 15:24:34 +01:00
*
* @package Netzmacht\Contao\Leaflet\Mapper\Layer
*/
class ReferenceLayerMapper extends AbstractLayerMapper
{
/**
* Layer type.
*
* @var string
*/
protected static $type = 'reference';
/**
* {@inheritdoc}
*/
2015-01-20 16:38:23 +01:00
public function handle($model, DefinitionMapper $mapper, LatLngBounds $bounds = null, $elementId = null, Definition $parent = null)
2015-01-09 15:24:34 +01:00
{
$reference = LayerModel::findByPk($model->reference);
if (!$reference || !$reference->active) {
return null;
}
$elementId = $model->standalone ? $this->getElementId($model, $elementId) : null;
return $mapper->handle($reference, $bounds, $elementId);
2015-01-09 15:24:34 +01:00
}
}