mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-29 03:24:37 +01:00
Use the repository manager.
This commit is contained in:
@@ -9,6 +9,8 @@ services:
|
||||
# Map mapper
|
||||
netzmacht.contao_leaflet.mapper.map:
|
||||
class: Netzmacht\Contao\Leaflet\Mapper\MapMapper
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
tags:
|
||||
- { name: netzmacht.contao_leaflet.mapper }
|
||||
|
||||
@@ -28,26 +30,36 @@ services:
|
||||
|
||||
netzmacht.contao_leaflet.mapper.markers_layer:
|
||||
class: Netzmacht\Contao\Leaflet\Mapper\Layer\MarkersLayerMapper
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
tags:
|
||||
- { name: netzmacht.contao_leaflet.mapper }
|
||||
|
||||
netzmacht.contao_leaflet.mapper.group_layer:
|
||||
class: Netzmacht\Contao\Leaflet\Mapper\Layer\GroupLayerMapper
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
tags:
|
||||
- { name: netzmacht.contao_leaflet.mapper }
|
||||
|
||||
netzmacht.contao_leaflet.mapper.vectors_layer:
|
||||
class: Netzmacht\Contao\Leaflet\Mapper\Layer\VectorsLayerMapper
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
tags:
|
||||
- { name: netzmacht.contao_leaflet.mapper }
|
||||
|
||||
netzmacht.contao_leaflet.mapper.reference_layer:
|
||||
class: Netzmacht\Contao\Leaflet\Mapper\Layer\ReferenceLayerMapper
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
tags:
|
||||
- { name: netzmacht.contao_leaflet.mapper }
|
||||
|
||||
netzmacht.contao_leaflet.mapper.overpass_layer:
|
||||
class: Netzmacht\Contao\Leaflet\Mapper\Layer\OverpassLayerMapper
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
tags:
|
||||
- { name: netzmacht.contao_leaflet.mapper }
|
||||
|
||||
@@ -55,11 +67,14 @@ services:
|
||||
class: Netzmacht\Contao\Leaflet\Mapper\Layer\MarkerClusterLayerMapper
|
||||
arguments:
|
||||
- '@netzmacht.contao_leaflet.map.assets'
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
tags:
|
||||
- { name: netzmacht.contao_leflet_maps.mapper }
|
||||
|
||||
netzmacht.contao_leaflet.mapper.file_layer:
|
||||
class: Netzmacht\Contao\Leaflet\Mapper\Layer\FileLayerMapper
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
tags:
|
||||
- { name: netzmacht.contao_leaflet.mapper }
|
||||
|
||||
@@ -86,6 +101,8 @@ services:
|
||||
|
||||
netzmacht.contao_leaflet.mapper.loading_control:
|
||||
class: Netzmacht\Contao\Leaflet\Mapper\Control\LoadingControlMapper
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
tags:
|
||||
- { name: netzmacht.contao_leaflet.mapper }
|
||||
|
||||
@@ -99,6 +116,7 @@ services:
|
||||
netzmacht.contao_leaflet.mapper.polyline:
|
||||
class: Netzmacht\Contao\Leaflet\Mapper\Vector\PolylineMapper
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
||||
tags:
|
||||
- { name: netzmacht.contao_leaflet.mapper }
|
||||
@@ -106,6 +124,7 @@ services:
|
||||
netzmacht.contao_leaflet.mapper.multi_polyline:
|
||||
class: Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolylineMapper
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
||||
tags:
|
||||
- { name: netzmacht.contao_leaflet.mapper }
|
||||
@@ -113,6 +132,7 @@ services:
|
||||
netzmacht.contao_leaflet.mapper.polygon:
|
||||
class: Netzmacht\Contao\Leaflet\Mapper\Vector\PolygonMapper
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
||||
tags:
|
||||
- { name: netzmacht.contao_leaflet.mapper }
|
||||
@@ -120,6 +140,7 @@ services:
|
||||
netzmacht.contao_leaflet.mapper.multi_polygon:
|
||||
class: Netzmacht\Contao\Leaflet\Mapper\Vector\MultiPolygonMapper
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
||||
tags:
|
||||
- { name: netzmacht.contao_leaflet.mapper }
|
||||
@@ -127,6 +148,7 @@ services:
|
||||
netzmacht.contao_leaflet.mapper.circle:
|
||||
class: Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMapper
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
||||
tags:
|
||||
- { name: netzmacht.contao_leaflet.mapper }
|
||||
@@ -134,6 +156,7 @@ services:
|
||||
netzmacht.contao_leaflet.mapper.circle_mapper:
|
||||
class: Netzmacht\Contao\Leaflet\Mapper\Vector\CircleMarkerMapper
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
||||
tags:
|
||||
- { name: netzmacht.contao_leaflet.mapper }
|
||||
@@ -141,6 +164,7 @@ services:
|
||||
netzmacht.contao_leaflet.mapper.rectangle_mapper:
|
||||
class: Netzmacht\Contao\Leaflet\Mapper\Vector\RectangleMapper
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
||||
tags:
|
||||
- { name: netzmacht.contao_leaflet.mapper }
|
||||
@@ -154,6 +178,8 @@ services:
|
||||
|
||||
netzmacht.contao_leaflet.mapper.image_icon:
|
||||
class: Netzmacht\Contao\Leaflet\Mapper\Type\ImageIconMapper
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
tags:
|
||||
- { name: netzmacht.contao_leaflet.mapper }
|
||||
|
||||
@@ -175,6 +201,7 @@ services:
|
||||
netzmacht.contao_leaflet.mapper.marker:
|
||||
class: Netzmacht\Contao\Leaflet\Mapper\UI\MarkerMapper
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
- '@netzmacht.contao_leaflet.frontend.value_filter'
|
||||
tags:
|
||||
- { name: netzmacht.contao_leaflet.mapper }
|
||||
|
||||
@@ -16,6 +16,7 @@ use Contao\Model;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||
use Netzmacht\Contao\Leaflet\Model\ControlModel;
|
||||
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
use Netzmacht\LeafletPHP\Definition\Control\Zoom;
|
||||
use Netzmacht\LeafletPHP\Plugins\Loading\LoadingControl;
|
||||
@@ -35,6 +36,25 @@ class LoadingControlMapper extends AbstractControlMapper
|
||||
*/
|
||||
protected static $type = 'loading';
|
||||
|
||||
/**
|
||||
* Repository manager.
|
||||
*
|
||||
* @var RepositoryManager
|
||||
*/
|
||||
private $repositoryManager;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param RepositoryManager $repositoryManager Repository manager.
|
||||
*/
|
||||
public function __construct(RepositoryManager $repositoryManager)
|
||||
{
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -79,7 +99,8 @@ class LoadingControlMapper extends AbstractControlMapper
|
||||
|
||||
if ($definition instanceof LoadingControl && !$definition->isSeparate() && $model->zoomControl) {
|
||||
// Only assign if zoom control is activated and part of the map.
|
||||
$control = ControlModel::findOneBy(
|
||||
$repository = $this->repositoryManager->getRepository(ControlModel::class);
|
||||
$control = $repository->findOneBy(
|
||||
['active=1', 'type=?', 'pid=?', 'id=?'],
|
||||
['zoom', $model->pid, $model->zoomControl]
|
||||
);
|
||||
|
||||
@@ -18,6 +18,7 @@ use Contao\FilesModel;
|
||||
use Contao\Model;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||
use Netzmacht\JavascriptBuilder\Type\Expression;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
use Netzmacht\LeafletPHP\Definition\Group\FeatureGroup;
|
||||
@@ -50,6 +51,25 @@ class FileLayerMapper extends AbstractLayerMapper
|
||||
*/
|
||||
protected static $definitionClass = FeatureGroup::class;
|
||||
|
||||
/**
|
||||
* Repository manager.
|
||||
*
|
||||
* @var RepositoryManager
|
||||
*/
|
||||
private $repositoryManager;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param RepositoryManager $repositoryManager Repository manager.
|
||||
*/
|
||||
public function __construct(RepositoryManager $repositoryManager)
|
||||
{
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -60,7 +80,8 @@ class FileLayerMapper extends AbstractLayerMapper
|
||||
$elementId = null,
|
||||
Definition $parent = null
|
||||
) {
|
||||
$fileModel = FilesModel::findByPk($model->file);
|
||||
$repository = $this->repositoryManager->getRepository(FilesModel::class);
|
||||
$fileModel = $repository->findByPk($model->file);
|
||||
$definition = $this->createInstance($model, $mapper, $request, $elementId, $fileModel);
|
||||
|
||||
$this->optionsBuilder->build($definition, $model);
|
||||
|
||||
@@ -16,6 +16,7 @@ use Contao\Model;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
use Netzmacht\LeafletPHP\Definition\Group\FeatureGroup;
|
||||
use Netzmacht\LeafletPHP\Definition\Group\LayerGroup;
|
||||
@@ -35,6 +36,25 @@ class GroupLayerMapper extends AbstractLayerMapper
|
||||
*/
|
||||
protected static $type = 'group';
|
||||
|
||||
/**
|
||||
* Repository manager.
|
||||
*
|
||||
* @var RepositoryManager
|
||||
*/
|
||||
private $repositoryManager;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param RepositoryManager $repositoryManager Repository manager.
|
||||
*/
|
||||
public function __construct(RepositoryManager $repositoryManager)
|
||||
{
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -61,7 +81,8 @@ class GroupLayerMapper extends AbstractLayerMapper
|
||||
return;
|
||||
}
|
||||
|
||||
$collection = LayerModel::findBy(
|
||||
$repository = $this->repositoryManager->getRepository(LayerModel::class);
|
||||
$collection = $repository->findBy(
|
||||
['pid=?', 'active=1'],
|
||||
[$model->id],
|
||||
['order' => 'sorting']
|
||||
|
||||
@@ -17,6 +17,7 @@ use Netzmacht\Contao\Leaflet\Encoder\ContaoAssets;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||
use Netzmacht\JavascriptBuilder\Type\AnonymousFunction;
|
||||
use Netzmacht\JavascriptBuilder\Type\Expression;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
@@ -53,15 +54,24 @@ class MarkerClusterLayerMapper extends AbstractLayerMapper
|
||||
private $assets;
|
||||
|
||||
/**
|
||||
* MarkerClusterLayerMapper constructor.
|
||||
* Repository manager.
|
||||
*
|
||||
* @param ContaoAssets $assets Assets manager.
|
||||
* @var RepositoryManager
|
||||
*/
|
||||
public function __construct(ContaoAssets $assets)
|
||||
{
|
||||
parent::__construct();
|
||||
private $repositoryManager;
|
||||
|
||||
$this->assets = $assets;
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param ContaoAssets $assets Assets manager.
|
||||
* @param RepositoryManager $repositoryManager Repository manager.
|
||||
*/
|
||||
public function __construct(ContaoAssets $assets, RepositoryManager $repositoryManager)
|
||||
{
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
$this->assets = $assets;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,7 +117,8 @@ class MarkerClusterLayerMapper extends AbstractLayerMapper
|
||||
$this->assets->addStylesheet('assets/leaflet/libs/leaflet-markercluster/MarkerCluster.Default.css');
|
||||
}
|
||||
|
||||
$collection = LayerModel::findBy(
|
||||
$repository = $this->repositoryManager->getRepository(LayerModel::class);
|
||||
$collection = $repository->findBy(
|
||||
['pid=?', 'active=1'],
|
||||
[$model->id],
|
||||
['order' => 'sorting']
|
||||
|
||||
@@ -18,6 +18,7 @@ use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\GeoJsonMapper;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||
use Netzmacht\Contao\Leaflet\Model\MarkerModel;
|
||||
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||
use Netzmacht\JavascriptBuilder\Type\Expression;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
use Netzmacht\LeafletPHP\Definition\Group\GeoJson;
|
||||
@@ -38,6 +39,25 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
*/
|
||||
protected static $type = 'markers';
|
||||
|
||||
/**
|
||||
* Repository manager.
|
||||
*
|
||||
* @var RepositoryManager
|
||||
*/
|
||||
private $repositoryManager;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param RepositoryManager $repositoryManager Repository manager.
|
||||
*/
|
||||
public function __construct(RepositoryManager $repositoryManager)
|
||||
{
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -154,10 +174,12 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
*/
|
||||
protected function loadMarkerModels(Model $model, Request $request = null)
|
||||
{
|
||||
$repository = $this->repositoryManager->getRepository(MarkerModel::class);
|
||||
|
||||
if ($model->boundsMode == 'fit') {
|
||||
return MarkerModel::findByFilter($model->id, $request->getFilter());
|
||||
return $repository->findByFilter($model->id, $request->getFilter());
|
||||
}
|
||||
|
||||
return MarkerModel::findByFilter($model->id);
|
||||
return $repository->findByFilter($model->id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ use Netzmacht\Contao\Leaflet\Definition\Layer\OverpassLayer;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
||||
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||
use Netzmacht\JavascriptBuilder\Type\Expression;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
|
||||
@@ -41,6 +42,25 @@ class OverpassLayerMapper extends AbstractLayerMapper
|
||||
*/
|
||||
protected static $definitionClass = OverpassLayer::class;
|
||||
|
||||
/**
|
||||
* Repository manager.
|
||||
*
|
||||
* @var RepositoryManager
|
||||
*/
|
||||
private $repositoryManager;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param RepositoryManager $repositoryManager Repository manager.
|
||||
*/
|
||||
public function __construct(RepositoryManager $repositoryManager)
|
||||
{
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -97,7 +117,8 @@ class OverpassLayerMapper extends AbstractLayerMapper
|
||||
$amenityIconsMap = $this->filterAmenityIconsConfig($model->amenityIcons);
|
||||
|
||||
if ($amenityIconsMap) {
|
||||
$collection = IconModel::findMultipleByIds(array_unique($amenityIconsMap));
|
||||
$repository = $this->repositoryManager->getRepository(IconModel::class);
|
||||
$collection = $repository->findMultipleByIds(array_unique($amenityIconsMap));
|
||||
$icons = [];
|
||||
|
||||
if ($collection) {
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
|
||||
/**
|
||||
@@ -31,6 +32,25 @@ class ReferenceLayerMapper extends AbstractLayerMapper
|
||||
*/
|
||||
protected static $type = 'reference';
|
||||
|
||||
/**
|
||||
* Repository manager.
|
||||
*
|
||||
* @var RepositoryManager
|
||||
*/
|
||||
private $repositoryManager;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param RepositoryManager $repositoryManager Repository manager.
|
||||
*/
|
||||
public function __construct(RepositoryManager $repositoryManager)
|
||||
{
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -41,7 +61,8 @@ class ReferenceLayerMapper extends AbstractLayerMapper
|
||||
$elementId = null,
|
||||
Definition $parent = null
|
||||
) {
|
||||
$reference = LayerModel::findByPk($model->reference);
|
||||
$repository = $this->repositoryManager->getRepository(LayerModel::class);
|
||||
$reference = $repository->findByPk($model->reference);
|
||||
|
||||
if (!$reference || !$reference->active) {
|
||||
return null;
|
||||
|
||||
@@ -19,6 +19,7 @@ use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\GeoJsonMapper;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||
use Netzmacht\Contao\Leaflet\Model\VectorModel;
|
||||
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||
use Netzmacht\JavascriptBuilder\Type\Expression;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
use Netzmacht\LeafletPHP\Definition\Group\GeoJson;
|
||||
@@ -39,6 +40,25 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
*/
|
||||
protected static $type = 'vectors';
|
||||
|
||||
/**
|
||||
* Repository manager.
|
||||
*
|
||||
* @var RepositoryManager
|
||||
*/
|
||||
private $repositoryManager;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param RepositoryManager $repositoryManager Repository manager.
|
||||
*/
|
||||
public function __construct(RepositoryManager $repositoryManager)
|
||||
{
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -159,7 +179,9 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
*/
|
||||
protected function loadVectorModels(Model $model)
|
||||
{
|
||||
return VectorModel::findActiveBy('pid', $model->id, ['order' => 'sorting']);
|
||||
$repository = $this->repositoryManager->getRepository(VectorModel::class);
|
||||
|
||||
return $repository->findActiveBy(['pid=?'], [$model->id], ['order' => 'sorting']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace Netzmacht\Contao\Leaflet\Mapper;
|
||||
use Contao\Model;
|
||||
use Netzmacht\Contao\Leaflet\Model\ControlModel;
|
||||
use Netzmacht\Contao\Leaflet\Model\MapModel;
|
||||
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
use Netzmacht\LeafletPHP\Definition\Control;
|
||||
use Netzmacht\LeafletPHP\Definition\Layer;
|
||||
@@ -41,6 +42,25 @@ class MapMapper extends AbstractMapper
|
||||
*/
|
||||
protected static $definitionClass = Map::class;
|
||||
|
||||
/**
|
||||
* Repository manager.
|
||||
*
|
||||
* @var RepositoryManager
|
||||
*/
|
||||
private $repositoryManager;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param RepositoryManager $repositoryManager Repository manager.
|
||||
*/
|
||||
public function __construct(RepositoryManager $repositoryManager)
|
||||
{
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -121,7 +141,8 @@ class MapMapper extends AbstractMapper
|
||||
*/
|
||||
private function buildControls(Map $map, MapModel $model, DefinitionMapper $mapper, Request $request = null)
|
||||
{
|
||||
$collection = ControlModel::findActiveBy('pid', $model->id, ['order' => 'sorting']);
|
||||
$repository = $this->repositoryManager->getRepository(ControlModel::class);
|
||||
$collection = $repository->findActiveBy(['pid=?'], [$model->id], ['order' => 'sorting']);
|
||||
|
||||
if (!$collection) {
|
||||
return;
|
||||
|
||||
@@ -12,10 +12,12 @@
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Mapper\Type;
|
||||
|
||||
use Contao\FilesModel;
|
||||
use Contao\Model;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
||||
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
use Netzmacht\LeafletPHP\Definition\Type\ImageIcon;
|
||||
|
||||
@@ -40,6 +42,25 @@ class ImageIconMapper extends AbstractIconMapper
|
||||
*/
|
||||
protected static $type = 'image';
|
||||
|
||||
/**
|
||||
* Repository manager.
|
||||
*
|
||||
* @var RepositoryManager
|
||||
*/
|
||||
private $repositoryManager;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param RepositoryManager $repositoryManager Repository manager.
|
||||
*/
|
||||
public function __construct(RepositoryManager $repositoryManager)
|
||||
{
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -52,7 +73,8 @@ class ImageIconMapper extends AbstractIconMapper
|
||||
$arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
||||
|
||||
if ($model->iconImage) {
|
||||
$file = \FilesModel::findByUuid($model->iconImage);
|
||||
$repository = $this->repositoryManager->getRepository(FilesModel::class);
|
||||
$file = $repository->findByUuid($model->iconImage);
|
||||
|
||||
if ($file) {
|
||||
$arguments[] = $file->path;
|
||||
@@ -88,8 +110,10 @@ class ImageIconMapper extends AbstractIconMapper
|
||||
*/
|
||||
private function addIcon(ImageIcon $definition, IconModel $model)
|
||||
{
|
||||
$repository = $this->repositoryManager->getRepository(FilesModel::class);
|
||||
|
||||
if ($model->iconImage) {
|
||||
$file = \FilesModel::findByUuid($model->iconImage);
|
||||
$file = $repository->findByUuid($model->iconImage);
|
||||
|
||||
if ($file) {
|
||||
$definition->setIconUrl($file->path);
|
||||
@@ -112,7 +136,7 @@ class ImageIconMapper extends AbstractIconMapper
|
||||
}
|
||||
|
||||
if ($model->iconRetinaImage) {
|
||||
$file = \FilesModel::findByUuid($model->iconRetinaImage);
|
||||
$file = $repository->findByUuid($model->iconRetinaImage);
|
||||
|
||||
if ($file) {
|
||||
$definition->setIconRetinaUrl($file->path);
|
||||
@@ -130,8 +154,10 @@ class ImageIconMapper extends AbstractIconMapper
|
||||
*/
|
||||
private function addShadow(ImageIcon $definition, $model)
|
||||
{
|
||||
$repository = $this->repositoryManager->getRepository(FilesModel::class);
|
||||
|
||||
if ($model->shadowImage) {
|
||||
$file = \FilesModel::findByUuid($model->shadowImage);
|
||||
$file = $repository->findByUuid($model->shadowImage);
|
||||
|
||||
if ($file) {
|
||||
$definition->setShadowUrl($file->path);
|
||||
@@ -150,7 +176,8 @@ class ImageIconMapper extends AbstractIconMapper
|
||||
}
|
||||
|
||||
if ($model->shadowRetinaImage) {
|
||||
$file = \FilesModel::findByUuid($model->shadowRetinaImage);
|
||||
|
||||
$file = $repository->findByUuid($model->shadowRetinaImage);
|
||||
|
||||
if ($file) {
|
||||
$definition->setShadowRetinaUrl($file->path);
|
||||
|
||||
@@ -20,6 +20,7 @@ use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
||||
use Netzmacht\Contao\Leaflet\Model\MarkerModel;
|
||||
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
||||
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
use Netzmacht\LeafletPHP\Definition\Type\ImageIcon;
|
||||
use Netzmacht\LeafletPHP\Definition\UI\Marker;
|
||||
@@ -53,16 +54,25 @@ class MarkerMapper extends AbstractMapper
|
||||
*/
|
||||
protected $valueFilter;
|
||||
|
||||
/**
|
||||
* Repository manager.
|
||||
*
|
||||
* @var RepositoryManager
|
||||
*/
|
||||
private $repositoryManager;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param ValueFilter $valueFilter Frontend filter.
|
||||
* @param RepositoryManager $repositoryManager Repository manager.
|
||||
* @param ValueFilter $valueFilter Frontend filter.
|
||||
*/
|
||||
public function __construct(ValueFilter $valueFilter)
|
||||
public function __construct(RepositoryManager $repositoryManager, ValueFilter $valueFilter)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
$this->valueFilter = $valueFilter;
|
||||
|
||||
$this->valueFilter = $valueFilter;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,7 +118,8 @@ class MarkerMapper extends AbstractMapper
|
||||
$content = $this->valueFilter->filter($model->popupContent);
|
||||
|
||||
if ($model->popup) {
|
||||
$popupModel = PopupModel::findActiveByPK($model->popup);
|
||||
$popupRepository = $this->repositoryManager->getRepository(PopupModel::class);
|
||||
$popupModel = $popupRepository->findActiveByPK($model->popup);
|
||||
|
||||
if ($popupModel) {
|
||||
$popup = $mapper->handle($popupModel, $request, null, $definition);
|
||||
@@ -123,7 +134,8 @@ class MarkerMapper extends AbstractMapper
|
||||
}
|
||||
|
||||
if ($model->customIcon) {
|
||||
$iconModel = IconModel::findBy(
|
||||
$iconRepository = $this->repositoryManager->getRepository(IconModel::class);
|
||||
$iconModel = $iconRepository->findBy(
|
||||
['id=?', 'active=1'],
|
||||
[$model->icon],
|
||||
['return' => 'Model']
|
||||
|
||||
@@ -21,6 +21,7 @@ use Netzmacht\Contao\Leaflet\Mapper\Request;
|
||||
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
||||
use Netzmacht\Contao\Leaflet\Model\StyleModel;
|
||||
use Netzmacht\Contao\Leaflet\Model\VectorModel;
|
||||
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||
use Netzmacht\LeafletPHP\Definition;
|
||||
use Netzmacht\LeafletPHP\Definition\HasPopup;
|
||||
use Netzmacht\LeafletPHP\Definition\UI\Popup;
|
||||
@@ -47,16 +48,25 @@ class AbstractVectorMapper extends AbstractTypeMapper
|
||||
*/
|
||||
protected $valueFilter;
|
||||
|
||||
/**
|
||||
* Repository manager.
|
||||
*
|
||||
* @var RepositoryManager
|
||||
*/
|
||||
private $repositoryManager;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param ValueFilter $valueFilter Frontend filter.
|
||||
* @param RepositoryManager $repositoryManager Repository manager.
|
||||
* @param ValueFilter $valueFilter Frontend filter.
|
||||
*/
|
||||
public function __construct(ValueFilter $valueFilter)
|
||||
public function __construct(RepositoryManager $repositoryManager, ValueFilter $valueFilter)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
$this->valueFilter = $valueFilter;
|
||||
|
||||
$this->valueFilter = $valueFilter;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +82,8 @@ class AbstractVectorMapper extends AbstractTypeMapper
|
||||
parent::build($definition, $model, $mapper, $request);
|
||||
|
||||
if ($definition instanceof Path && $model->style) {
|
||||
$styleModel = StyleModel::findActiveByPK($model->style);
|
||||
$repository = $this->repositoryManager->getRepository(StyleModel::class);
|
||||
$styleModel = $repository->findActiveByPK($model->style);
|
||||
|
||||
if ($styleModel) {
|
||||
$style = $mapper->handle($styleModel);
|
||||
@@ -107,7 +118,8 @@ class AbstractVectorMapper extends AbstractTypeMapper
|
||||
$content = $this->valueFilter->filter($model->popupContent);
|
||||
|
||||
if ($model->popup) {
|
||||
$popupModel = PopupModel::findActiveByPK($model->popup);
|
||||
$repository = $this->repositoryManager->getRepository(PopupModel::class);
|
||||
$popupModel = $repository->findActiveByPK($model->popup);
|
||||
|
||||
if ($popupModel) {
|
||||
$popup = $mapper->handle($popupModel, $request, null, $definition);
|
||||
|
||||
Reference in New Issue
Block a user