forked from Snck3rs/contao-leaflet-maps
Work on repository manager usage.
This commit is contained in:
@@ -26,6 +26,7 @@ services:
|
||||
- '@netzmacht.contao_toolkit.dca.manager'
|
||||
- '@database_connection'
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
|
||||
netzmacht.contao_leaflet.listeners.dca.control:
|
||||
class: Netzmacht\Contao\Leaflet\Listener\Dca\ControlDcaListener
|
||||
@@ -74,6 +75,7 @@ services:
|
||||
netzmacht.contao_leaflet.listeners.geo_json_listener:
|
||||
class: Netzmacht\Contao\Leaflet\Listener\GeoJsonListener
|
||||
arguments:
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
- '%netzmacht.contao_leaflet.feature_model_properties%'
|
||||
tags:
|
||||
- { name: 'kernel.event_listener', event: 'netzmacht.contao_leaflet.mapper.convert_to_geojson', method: 'handle' }
|
||||
@@ -88,6 +90,7 @@ services:
|
||||
arguments:
|
||||
- '@netzmacht.contao_leaflet.map.assets'
|
||||
- '@netzmacht.contao_leaflet.definition.mapper'
|
||||
- '@netzmacht.contao_toolkit.repository_manager'
|
||||
- '@netzmacht.contao_leaflet.libraries'
|
||||
tags:
|
||||
- { name: 'kernel.event_listener', event: 'netzmacht.contao_leaflet.get_javascript', method: 'onGetJavascriptEvent' }
|
||||
|
||||
@@ -90,7 +90,8 @@ abstract class AbstractMapHybrid extends AbstractHybrid
|
||||
$this->mapProvider->handleAjaxRequest($this->getIdentifier());
|
||||
|
||||
if (TL_MODE === 'BE') {
|
||||
$model = MapModel::findByPk($this->get('leaflet_map'));
|
||||
$repository = $this->repositoryManager->getRepository(MapModel::class);
|
||||
$model = $repository->find((int) $this->get('leaflet_map'));
|
||||
$parameters = [
|
||||
'title' => $this->get('headline'),
|
||||
];
|
||||
|
||||
@@ -14,9 +14,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Listener;
|
||||
|
||||
use Contao\FilesModel;
|
||||
use Contao\Model;
|
||||
use Netzmacht\Contao\Leaflet\Event\ConvertToGeoJsonEvent;
|
||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||
use Netzmacht\LeafletPHP\Definition as LeafletDefinition;
|
||||
use Netzmacht\LeafletPHP\Definition\HasPopup;
|
||||
use Netzmacht\LeafletPHP\Definition\UI\Marker;
|
||||
@@ -40,13 +42,22 @@ final class GeoJsonListener
|
||||
*/
|
||||
private $featureModelProperties;
|
||||
|
||||
/**
|
||||
* Repository manager.
|
||||
*
|
||||
* @var RepositoryManager
|
||||
*/
|
||||
private $repositoryManager;
|
||||
|
||||
/**
|
||||
* GeoJsonSubscriber constructor.
|
||||
*
|
||||
* @param array $featureModelProperties Property mapping between models and features.
|
||||
* @param RepositoryManager $repositoryManager Repository manager.
|
||||
* @param array $featureModelProperties Property mapping between models and features.
|
||||
*/
|
||||
public function __construct(array $featureModelProperties)
|
||||
public function __construct(RepositoryManager $repositoryManager, array $featureModelProperties)
|
||||
{
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
$this->featureModelProperties = $featureModelProperties;
|
||||
}
|
||||
|
||||
@@ -176,12 +187,14 @@ final class GeoJsonListener
|
||||
break;
|
||||
|
||||
case 'file':
|
||||
$file = \FilesModel::findByUuid($value);
|
||||
$value = $file->path;
|
||||
$repository = $this->repositoryManager->getRepository(FilesModel::class);
|
||||
$file = $repository->findByUuid($value);
|
||||
$value = $file->path;
|
||||
break;
|
||||
|
||||
case 'files':
|
||||
$collection = \FilesModel::findMultipleByUuids(deserialize($value, true));
|
||||
$repository = $this->repositoryManager->getRepository(FilesModel::class);
|
||||
$collection = $repository->findMultipleByUuids(deserialize($value, true));
|
||||
|
||||
if ($collection) {
|
||||
$value = $collection->fetchEach('path');
|
||||
@@ -213,7 +226,8 @@ final class GeoJsonListener
|
||||
if ($model->ignoreForBounds) {
|
||||
$feature->setProperty('ignoreForBounds', true);
|
||||
} else {
|
||||
$parent = LayerModel::findByPk($model->pid);
|
||||
$repository = $this->repositoryManager->getRepository(LayerModel::class);
|
||||
$parent = $repository->find((int) $model->pid);
|
||||
|
||||
if ($parent && $parent->boundsMode !== 'extend') {
|
||||
$feature->setProperty('ignoreForBounds', true);
|
||||
|
||||
@@ -18,6 +18,7 @@ use Netzmacht\Contao\Leaflet\Encoder\ContaoAssets;
|
||||
use Netzmacht\Contao\Leaflet\Frontend\Assets\LibrariesConfiguration;
|
||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
||||
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
|
||||
use Netzmacht\LeafletPHP\Assets;
|
||||
use Netzmacht\LeafletPHP\Definition\Type\Icon;
|
||||
use Netzmacht\LeafletPHP\Definition\Type\ImageIcon;
|
||||
@@ -50,18 +51,31 @@ class LoadAssetsListener
|
||||
*/
|
||||
private $libraries;
|
||||
|
||||
/**
|
||||
* Repository manager.
|
||||
*
|
||||
* @var RepositoryManager
|
||||
*/
|
||||
private $repositoryManager;
|
||||
|
||||
/**
|
||||
* LoadAssetsListener constructor.
|
||||
*
|
||||
* @param Assets $assets Assets.
|
||||
* @param DefinitionMapper $definitionMapper Definition mapper.
|
||||
* @param LibrariesConfiguration $libraries Libraries.
|
||||
* @param Assets $assets Assets.
|
||||
* @param DefinitionMapper $definitionMapper Definition mapper.
|
||||
* @param RepositoryManager $repositoryManager Repository manager.
|
||||
* @param LibrariesConfiguration $libraries Libraries.
|
||||
*/
|
||||
public function __construct(Assets $assets, DefinitionMapper $definitionMapper, LibrariesConfiguration $libraries)
|
||||
{
|
||||
$this->assets = $assets;
|
||||
$this->definitionMapper = $definitionMapper;
|
||||
$this->libraries = $libraries;
|
||||
public function __construct(
|
||||
Assets $assets,
|
||||
DefinitionMapper $definitionMapper,
|
||||
RepositoryManager $repositoryManager,
|
||||
LibrariesConfiguration $libraries
|
||||
) {
|
||||
$this->assets = $assets;
|
||||
$this->definitionMapper = $definitionMapper;
|
||||
$this->libraries = $libraries;
|
||||
$this->repositoryManager = $repositoryManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +90,8 @@ class LoadAssetsListener
|
||||
ContaoAssets::TYPE_FILE
|
||||
);
|
||||
|
||||
$collection = IconModel::findBy('active', true);
|
||||
$repository = $this->repositoryManager->getRepository(IconModel::class);
|
||||
$collection = $repository->findBy(['active=?'], [true]);
|
||||
|
||||
if ($collection) {
|
||||
$buffer = '';
|
||||
|
||||
Reference in New Issue
Block a user