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,77 @@
<?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\Layer;
use Netzmacht\Contao\Leaflet\Filter\Filter;
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\Contao\Leaflet\Model\LayerModel;
use Netzmacht\LeafletPHP\Definition;
use Netzmacht\LeafletPHP\Definition\Group\LayerGroup;
use Netzmacht\LeafletPHP\Definition\Layer;
/**
* Class GroupLayerMapper maps the layer model to the group layer definition.
*
* @package Netzmacht\Contao\Leaflet\Mapper\Layer
*/
class GroupLayerMapper extends AbstractLayerMapper
{
/**
* Layer type.
*
* @var string
*/
protected static $type = 'group';
/**
* {@inheritdoc}
*/
protected function getClassName(\Model $model, DefinitionMapper $mapper, Filter $filter = null)
{
if ($model->groupType === 'feature') {
return 'Netzmacht\LeafletPHP\Definition\Group\FeatureGroup';
}
return 'Netzmacht\LeafletPHP\Definition\Group\LayerGroup';
}
/**
* {@inheritdoc}
*/
protected function build(
Definition $definition,
\Model $model,
DefinitionMapper $mapper,
Filter $filter = null,
Definition $parent = null
) {
if (!$definition instanceof LayerGroup) {
return;
}
$collection = LayerModel::findBy(
array('pid=?', 'active=1'),
array($model->id),
array('order' => 'sorting')
);
if ($collection) {
foreach ($collection as $layerModel) {
$layer = $mapper->handle($layerModel);
if ($layer instanceof Layer) {
$definition->addLayer($layer);
}
}
}
}
}