forked from Snck3rs/contao-leaflet-maps
Rework filter handling to overcome static map identifier setting.
This commit is contained in:
@@ -12,8 +12,8 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Event;
|
namespace Netzmacht\Contao\Leaflet\Event;
|
||||||
|
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Value\LatLngBounds;
|
|
||||||
use Symfony\Component\EventDispatcher\Event;
|
use Symfony\Component\EventDispatcher\Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,24 +40,24 @@ class BuildDefinitionEvent extends Event
|
|||||||
private $model;
|
private $model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional bounds where elements should be in.
|
* Building request.
|
||||||
*
|
*
|
||||||
* @var LatLngBounds
|
* @var Request|null
|
||||||
*/
|
*/
|
||||||
private $bounds;
|
private $request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct.
|
* Construct.
|
||||||
*
|
*
|
||||||
* @param Definition $definition The leaflet definition.
|
* @param Definition $definition The leaflet definition.
|
||||||
* @param \Model $model The definition model.
|
* @param \Model $model The definition model.
|
||||||
* @param LatLngBounds $bounds Optional bounds where elements should be in.
|
* @param Request|null $request Building request.
|
||||||
*/
|
*/
|
||||||
public function __construct(Definition $definition, \Model $model, LatLngBounds $bounds = null)
|
public function __construct(Definition $definition, \Model $model, Request $request = null)
|
||||||
{
|
{
|
||||||
$this->definition = $definition;
|
$this->definition = $definition;
|
||||||
$this->model = $model;
|
$this->model = $model;
|
||||||
$this->bounds = $bounds;
|
$this->request = $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,10 +83,10 @@ class BuildDefinitionEvent extends Event
|
|||||||
/**
|
/**
|
||||||
* Get the bounds.
|
* Get the bounds.
|
||||||
*
|
*
|
||||||
* @return LatLngBounds|null
|
* @return Request|null
|
||||||
*/
|
*/
|
||||||
public function getBounds()
|
public function getRequest()
|
||||||
{
|
{
|
||||||
return $this->bounds;
|
return $this->request;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
namespace Netzmacht\Contao\Leaflet\Frontend;
|
namespace Netzmacht\Contao\Leaflet\Frontend;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RequestUrl creates the request url.
|
* Class RequestUrl creates the request url.
|
||||||
@@ -21,13 +22,6 @@ use Netzmacht\Contao\Leaflet\Filter\Filter;
|
|||||||
*/
|
*/
|
||||||
class RequestUrl implements \JsonSerializable
|
class RequestUrl implements \JsonSerializable
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The for param is the identifier to the responsible frontend module or content element.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private static $for;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The leaflet hash.
|
* The leaflet hash.
|
||||||
*
|
*
|
||||||
@@ -54,17 +48,17 @@ class RequestUrl implements \JsonSerializable
|
|||||||
*
|
*
|
||||||
* It combines the params and creates an hash for it.
|
* It combines the params and creates an hash for it.
|
||||||
*
|
*
|
||||||
* @param int $dataId The data object id.
|
* @param int $dataId The data object id.
|
||||||
* @param string|null $type Object type. If empty it assumes a layer.
|
* @param string|null $type Object type. If empty it assumes a layer.
|
||||||
* @param string|null $format Data format. If empty it assumes geojson.
|
* @param string|null $format Data format. If empty it assumes geojson.
|
||||||
* @param Filter $filter Optional filter.
|
* @param Request $request Optional building request.
|
||||||
*
|
*
|
||||||
* @return RequestUrl
|
* @return RequestUrl
|
||||||
*/
|
*/
|
||||||
public static function create($dataId, $type = null, $format = null, Filter $filter = null)
|
public static function create($dataId, $type = null, $format = null, Request $request = null)
|
||||||
{
|
{
|
||||||
$params = array(
|
$params = array(
|
||||||
'for' => static::$for,
|
'for' => $request ? $request->getMapIdentifier() : null,
|
||||||
'type' => $type != 'layer' ? $type : null,
|
'type' => $type != 'layer' ? $type : null,
|
||||||
'id' => $dataId,
|
'id' => $dataId,
|
||||||
'format' => $format != 'geojson' ? $format : null
|
'format' => $format != 'geojson' ? $format : null
|
||||||
@@ -73,25 +67,14 @@ class RequestUrl implements \JsonSerializable
|
|||||||
$hash = base64_encode(implode(',', $params));
|
$hash = base64_encode(implode(',', $params));
|
||||||
$query = 'leaflet=' . $hash;
|
$query = 'leaflet=' . $hash;
|
||||||
|
|
||||||
if ($filter) {
|
if ($request && $request->getFilter()) {
|
||||||
|
$filter = $request->getFilter();
|
||||||
$query .= '&f=' . $filter->getName() . '&v=' . $filter->toRequest();
|
$query .= '&f=' . $filter->getName() . '&v=' . $filter->toRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = \Config::get('websitePath') . '/' . \Frontend::addToUrl($query, false);
|
$url = \Config::get('websitePath') . '/' . \Frontend::addToUrl($query, false);
|
||||||
|
|
||||||
return new static($url, $hash, $filter);
|
return new static($url, $hash, $request);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the for param.
|
|
||||||
*
|
|
||||||
* @param string $for The identifier which has the responsibility listen to the request.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function setFor($for)
|
|
||||||
{
|
|
||||||
static::$for = $for;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ use Doctrine\Common\Cache\Cache;
|
|||||||
use Netzmacht\Contao\Leaflet\Event\GetJavascriptEvent;
|
use Netzmacht\Contao\Leaflet\Event\GetJavascriptEvent;
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
||||||
use Netzmacht\Contao\Leaflet\Frontend\DataController;
|
use Netzmacht\Contao\Leaflet\Frontend\DataController;
|
||||||
use Netzmacht\Contao\Leaflet\Frontend\RequestUrl;
|
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||||
use Netzmacht\Contao\Leaflet\Model\MapModel;
|
use Netzmacht\Contao\Leaflet\Model\MapModel;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Value\GeoJson\FeatureCollection;
|
use Netzmacht\LeafletPHP\Value\GeoJson\FeatureCollection;
|
||||||
use Netzmacht\LeafletPHP\Definition\Map;
|
use Netzmacht\LeafletPHP\Definition\Map;
|
||||||
use Netzmacht\LeafletPHP\Leaflet;
|
use Netzmacht\LeafletPHP\Leaflet;
|
||||||
@@ -139,9 +139,8 @@ class MapProvider
|
|||||||
$model = $this->getModel($mapId);
|
$model = $this->getModel($mapId);
|
||||||
}
|
}
|
||||||
|
|
||||||
RequestUrl::setFor($elementId ?: $mapId);
|
$request = new Request($elementId ?: $mapId, $filter);
|
||||||
$definition = $this->mapper->reset()->handle($model, $filter, $elementId);
|
$definition = $this->mapper->reset()->handle($model, $request, $elementId);
|
||||||
RequestUrl::setFor(null);
|
|
||||||
|
|
||||||
return $definition;
|
return $definition;
|
||||||
}
|
}
|
||||||
@@ -241,8 +240,10 @@ class MapProvider
|
|||||||
throw new \InvalidArgumentException(sprintf('Could not find layer "%s"', $layerId));
|
throw new \InvalidArgumentException(sprintf('Could not find layer "%s"', $layerId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$request = new Request('', $filter);
|
||||||
|
|
||||||
if (!$model->cache) {
|
if (!$model->cache) {
|
||||||
return $this->mapper->handleGeoJson($model, $filter);
|
return $this->mapper->handleGeoJson($model, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
$cacheKey = 'feature_layer_' . $model->id;
|
$cacheKey = 'feature_layer_' . $model->id;
|
||||||
@@ -254,7 +255,7 @@ class MapProvider
|
|||||||
return $this->cache->fetch($cacheKey);
|
return $this->cache->fetch($cacheKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
$collection = $this->mapper->handleGeoJson($model, $filter);
|
$collection = $this->mapper->handleGeoJson($model, $request);
|
||||||
$this->cache->save($cacheKey, $collection, $model->cacheLifeTime);
|
$this->cache->save($cacheKey, $collection, $model->cacheLifeTime);
|
||||||
|
|
||||||
return $collection;
|
return $collection;
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper;
|
namespace Netzmacht\Contao\Leaflet\Mapper;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,14 +64,14 @@ abstract class AbstractMapper implements Mapper
|
|||||||
public function handle(
|
public function handle(
|
||||||
$model,
|
$model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
$elementId = null,
|
$elementId = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
$definition = $this->createInstance($model, $mapper, $filter, $elementId);
|
$definition = $this->createInstance($model, $mapper, $request, $elementId);
|
||||||
|
|
||||||
$this->optionsBuilder->build($definition, $model);
|
$this->optionsBuilder->build($definition, $model);
|
||||||
$this->build($definition, $model, $mapper, $filter, $parent);
|
$this->build($definition, $model, $mapper, $request, $parent);
|
||||||
|
|
||||||
return $definition;
|
return $definition;
|
||||||
}
|
}
|
||||||
@@ -78,7 +79,7 @@ abstract class AbstractMapper implements Mapper
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function match($model, Filter $filter = null)
|
public function match($model, Request $request = null)
|
||||||
{
|
{
|
||||||
$modelClass = static::$modelClass;
|
$modelClass = static::$modelClass;
|
||||||
|
|
||||||
@@ -98,9 +99,9 @@ abstract class AbstractMapper implements Mapper
|
|||||||
* Use for specific build methods.
|
* Use for specific build methods.
|
||||||
*
|
*
|
||||||
* @param Definition $definition The definition being built.
|
* @param Definition $definition The definition being built.
|
||||||
* @param \Model $model The model.
|
* @param Model $model The model.
|
||||||
* @param DefinitionMapper $mapper The definition mapper.
|
* @param DefinitionMapper $mapper The definition mapper.
|
||||||
* @param Filter|null $filter Optional request filter.
|
* @param Request $request Optional building request.
|
||||||
* @param Definition|null $parent The parent object.
|
* @param Definition|null $parent The parent object.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
@@ -109,9 +110,9 @@ abstract class AbstractMapper implements Mapper
|
|||||||
*/
|
*/
|
||||||
protected function build(
|
protected function build(
|
||||||
Definition $definition,
|
Definition $definition,
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
@@ -119,21 +120,21 @@ abstract class AbstractMapper implements Mapper
|
|||||||
/**
|
/**
|
||||||
* Create a new definition instance.
|
* Create a new definition instance.
|
||||||
*
|
*
|
||||||
* @param \Model $model The model.
|
* @param Model $model The model.
|
||||||
* @param DefinitionMapper $mapper The definition mapper.
|
* @param DefinitionMapper $mapper The definition mapper.
|
||||||
* @param Filter $filter Optional request filter.
|
* @param Request $request Optional building request.
|
||||||
* @param string|null $elementId Optional element id.
|
* @param string|null $elementId Optional element id.
|
||||||
*
|
*
|
||||||
* @return Definition
|
* @return Definition
|
||||||
*/
|
*/
|
||||||
protected function createInstance(
|
protected function createInstance(
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
$elementId = null
|
$elementId = null
|
||||||
) {
|
) {
|
||||||
$reflector = new \ReflectionClass($this->getClassName($model, $mapper, $filter));
|
$reflector = new \ReflectionClass($this->getClassName($model, $mapper, $request));
|
||||||
$instance = $reflector->newInstanceArgs($this->buildConstructArguments($model, $mapper, $filter, $elementId));
|
$instance = $reflector->newInstanceArgs($this->buildConstructArguments($model, $mapper, $request, $elementId));
|
||||||
|
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
@@ -141,9 +142,9 @@ abstract class AbstractMapper implements Mapper
|
|||||||
/**
|
/**
|
||||||
* Get construct arguments.
|
* Get construct arguments.
|
||||||
*
|
*
|
||||||
* @param \Model $model The model.
|
* @param Model $model The model.
|
||||||
* @param DefinitionMapper $mapper The definition mapper.
|
* @param DefinitionMapper $mapper The definition mapper.
|
||||||
* @param Filter $filter Optional request filter.
|
* @param Request $request Optional building request.
|
||||||
* @param string|null $elementId Optional element id.
|
* @param string|null $elementId Optional element id.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
@@ -151,9 +152,9 @@ abstract class AbstractMapper implements Mapper
|
|||||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*/
|
*/
|
||||||
protected function buildConstructArguments(
|
protected function buildConstructArguments(
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
$elementId = null
|
$elementId = null
|
||||||
) {
|
) {
|
||||||
return array(
|
return array(
|
||||||
@@ -164,15 +165,15 @@ abstract class AbstractMapper implements Mapper
|
|||||||
/**
|
/**
|
||||||
* Get definition class name.
|
* Get definition class name.
|
||||||
*
|
*
|
||||||
* @param \Model $model The model.
|
* @param Model $model The model.
|
||||||
* @param DefinitionMapper $mapper The definition mapper.
|
* @param DefinitionMapper $mapper The definition mapper.
|
||||||
* @param Filter $filter Optional request filter.
|
* @param Request $request Optional building request.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
*/
|
*/
|
||||||
protected function getClassName(\Model $model, DefinitionMapper $mapper, Filter $filter = null)
|
protected function getClassName(Model $model, DefinitionMapper $mapper, Request $request = null)
|
||||||
{
|
{
|
||||||
return static::$definitionClass;
|
return static::$definitionClass;
|
||||||
}
|
}
|
||||||
@@ -180,12 +181,12 @@ abstract class AbstractMapper implements Mapper
|
|||||||
/**
|
/**
|
||||||
* Create element id for the model.
|
* Create element id for the model.
|
||||||
*
|
*
|
||||||
* @param \Model $model The model being passed.
|
* @param Model $model The model being passed.
|
||||||
* @param string|null $elementId Optional forced id.
|
* @param string|null $elementId Optional forced id.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getElementId(\Model $model, $elementId = null)
|
protected function getElementId(Model $model, $elementId = null)
|
||||||
{
|
{
|
||||||
if ($elementId) {
|
if ($elementId) {
|
||||||
return $elementId;
|
return $elementId;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper;
|
namespace Netzmacht\Contao\Leaflet\Mapper;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AbstractTypeMapper is the base mapper for tables containing different types of definitins.
|
* Class AbstractTypeMapper is the base mapper for tables containing different types of definitins.
|
||||||
@@ -31,7 +31,7 @@ abstract class AbstractTypeMapper extends AbstractMapper
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function match($model, Filter $filter = null)
|
public function match($model, Request $request = null)
|
||||||
{
|
{
|
||||||
return parent::match($model) && $model->type === static::$type;
|
return parent::match($model) && $model->type === static::$type;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,9 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Control\Attribution;
|
use Netzmacht\LeafletPHP\Definition\Control\Attribution;
|
||||||
use Netzmacht\LeafletPHP\Definition\Map;
|
use Netzmacht\LeafletPHP\Definition\Map;
|
||||||
@@ -54,9 +55,9 @@ class AttributionControlMapper extends AbstractControlMapper
|
|||||||
*/
|
*/
|
||||||
protected function build(
|
protected function build(
|
||||||
Definition $definition,
|
Definition $definition,
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
if (!$definition instanceof Attribution) {
|
if (!$definition instanceof Attribution) {
|
||||||
|
|||||||
@@ -12,9 +12,10 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Model\ControlModel;
|
use Netzmacht\Contao\Leaflet\Model\ControlModel;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class LayersControlMapper maps the control model to the layers control definition.
|
* Class LayersControlMapper maps the control model to the layers control definition.
|
||||||
@@ -41,12 +42,12 @@ class LayersControlMapper extends AbstractControlMapper
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function buildConstructArguments(
|
protected function buildConstructArguments(
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
$elementId = null
|
$elementId = null
|
||||||
) {
|
) {
|
||||||
$arguments = parent::buildConstructArguments($model, $mapper, $filter, $elementId);
|
$arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
||||||
$arguments[1] = array();
|
$arguments[1] = array();
|
||||||
$arguments[2] = array();
|
$arguments[2] = array();
|
||||||
|
|
||||||
@@ -57,7 +58,7 @@ class LayersControlMapper extends AbstractControlMapper
|
|||||||
foreach ($collection as $layer) {
|
foreach ($collection as $layer) {
|
||||||
$argument = ($layer->controlMode === 'overlay') ? 2 : 1;
|
$argument = ($layer->controlMode === 'overlay') ? 2 : 1;
|
||||||
|
|
||||||
$arguments[$argument][] = $mapper->handle($layer, $filter);
|
$arguments[$argument][] = $mapper->handle($layer, $request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,10 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Control;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Model\ControlModel;
|
use Netzmacht\Contao\Leaflet\Model\ControlModel;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Control\Zoom;
|
use Netzmacht\LeafletPHP\Definition\Control\Zoom;
|
||||||
use Netzmacht\LeafletPHP\Plugins\Loading\LoadingControl;
|
use Netzmacht\LeafletPHP\Plugins\Loading\LoadingControl;
|
||||||
@@ -37,7 +38,7 @@ class LoadingControlMapper extends AbstractControlMapper
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function getClassName(\Model $model, DefinitionMapper $mapper, Filter $filter = null)
|
protected function getClassName(Model $model, DefinitionMapper $mapper, Request $request = null)
|
||||||
{
|
{
|
||||||
if ($model->spinjs) {
|
if ($model->spinjs) {
|
||||||
return 'Netzmacht\LeafletPHP\Plugins\Loading\SpinJsLoadingControl';
|
return 'Netzmacht\LeafletPHP\Plugins\Loading\SpinJsLoadingControl';
|
||||||
@@ -61,12 +62,12 @@ class LoadingControlMapper extends AbstractControlMapper
|
|||||||
*/
|
*/
|
||||||
protected function build(
|
protected function build(
|
||||||
Definition $definition,
|
Definition $definition,
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
parent::build($definition, $model, $mapper, $filter);
|
parent::build($definition, $model, $mapper, $request);
|
||||||
|
|
||||||
if ($definition instanceof SpinJsLoadingControl && $model->spin) {
|
if ($definition instanceof SpinJsLoadingControl && $model->spin) {
|
||||||
$config = json_decode($model->spin, true);
|
$config = json_decode($model->spin, true);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace Netzmacht\Contao\Leaflet\Mapper;
|
|||||||
use Netzmacht\Contao\Leaflet\Event\BuildDefinitionEvent;
|
use Netzmacht\Contao\Leaflet\Event\BuildDefinitionEvent;
|
||||||
use Netzmacht\Contao\Leaflet\Event\ConvertToGeoJsonEvent;
|
use Netzmacht\Contao\Leaflet\Event\ConvertToGeoJsonEvent;
|
||||||
use Netzmacht\Contao\Leaflet\Event\GetHashEvent;
|
use Netzmacht\Contao\Leaflet\Event\GetHashEvent;
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Value\GeoJson\ConvertsToGeoJsonFeature;
|
use Netzmacht\LeafletPHP\Value\GeoJson\ConvertsToGeoJsonFeature;
|
||||||
use Netzmacht\LeafletPHP\Value\GeoJson\Feature;
|
use Netzmacht\LeafletPHP\Value\GeoJson\Feature;
|
||||||
@@ -94,24 +94,24 @@ class DefinitionMapper
|
|||||||
* Build a model.
|
* Build a model.
|
||||||
*
|
*
|
||||||
* @param mixed $model The definition model.
|
* @param mixed $model The definition model.
|
||||||
* @param Filter $filter Optional request filter.
|
* @param Request|null $request The map request.
|
||||||
* @param string $elementId Optional element id. If none given the mapId or alias is used.
|
* @param string|null $elementId Optional element id. If none given the model id or alias is used.
|
||||||
* @param Definition|null $parent Optional pass the parent object.
|
* @param Definition|null $parent Optional pass the parent object.
|
||||||
*
|
*
|
||||||
* @return Definition|null
|
* @return Definition|null
|
||||||
*
|
*
|
||||||
* @throws \RuntimeException If model could not be mapped to a definition.
|
* @throws \RuntimeException If model could not be mapped to a definition.
|
||||||
*/
|
*/
|
||||||
public function handle($model, Filter $filter = null, $elementId = null, $parent = null)
|
public function handle($model, Request $request = null, $elementId = null, $parent = null)
|
||||||
{
|
{
|
||||||
$hash = $this->hash($model, $elementId);
|
$hash = $this->hash($model, $elementId);
|
||||||
|
|
||||||
if (!isset($this->mapped[$hash])) {
|
if (!isset($this->mapped[$hash])) {
|
||||||
$mapper = $this->getMapper($model);
|
$mapper = $this->getMapper($model);
|
||||||
$definition = $mapper->handle($model, $this, $filter, $elementId, $parent);
|
$definition = $mapper->handle($model, $this, $request, $elementId, $parent);
|
||||||
|
|
||||||
if ($definition) {
|
if ($definition) {
|
||||||
$event = new BuildDefinitionEvent($definition, $model, $filter);
|
$event = new BuildDefinitionEvent($definition, $model, $request);
|
||||||
$this->eventDispatcher->dispatch($event::NAME, $event);
|
$this->eventDispatcher->dispatch($event::NAME, $event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,19 +124,19 @@ class DefinitionMapper
|
|||||||
/**
|
/**
|
||||||
* Build a model.
|
* Build a model.
|
||||||
*
|
*
|
||||||
* @param mixed $model The definition model.
|
* @param mixed $model The definition model.
|
||||||
* @param Filter $filter Optional request filter.
|
* @param Request $request Optional building request.
|
||||||
*
|
*
|
||||||
* @return FeatureCollection|Feature|null
|
* @return FeatureCollection|Feature|null
|
||||||
*
|
*
|
||||||
* @throws \RuntimeException If a model could not be mapped to the GeoJSON representation.
|
* @throws \RuntimeException If a model could not be mapped to the GeoJSON representation.
|
||||||
*/
|
*/
|
||||||
public function handleGeoJson($model, Filter $filter = null)
|
public function handleGeoJson($model, Request $request = null)
|
||||||
{
|
{
|
||||||
$mapper = $this->getMapper($model);
|
$mapper = $this->getMapper($model);
|
||||||
|
|
||||||
if ($mapper instanceof GeoJsonMapper) {
|
if ($mapper instanceof GeoJsonMapper) {
|
||||||
return $mapper->handleGeoJson($model, $this, $filter);
|
return $mapper->handleGeoJson($model, $this, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \RuntimeException(
|
throw new \RuntimeException(
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper;
|
namespace Netzmacht\Contao\Leaflet\Mapper;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Value\GeoJson\GeoJsonFeature;
|
use Netzmacht\LeafletPHP\Value\GeoJson\GeoJsonFeature;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,11 +26,11 @@ interface GeoJsonMapper
|
|||||||
/**
|
/**
|
||||||
* Hanle the GeoJSON creation.
|
* Hanle the GeoJSON creation.
|
||||||
*
|
*
|
||||||
* @param \Model $model The model being mapped.
|
* @param Model $model The model being mapped.
|
||||||
* @param DefinitionMapper $mapper The definition mapper.
|
* @param DefinitionMapper $mapper The definition mapper.
|
||||||
* @param Filter $filter Optional request filter.
|
* @param Request $request Optional building request.
|
||||||
*
|
*
|
||||||
* @return GeoJsonFeature|null
|
* @return GeoJsonFeature|null
|
||||||
*/
|
*/
|
||||||
public function handleGeoJson(\Model $model, DefinitionMapper $mapper, Filter $filter = null);
|
public function handleGeoJson(Model $model, DefinitionMapper $mapper, Request $request = null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,10 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Group\LayerGroup;
|
use Netzmacht\LeafletPHP\Definition\Group\LayerGroup;
|
||||||
use Netzmacht\LeafletPHP\Definition\Layer;
|
use Netzmacht\LeafletPHP\Definition\Layer;
|
||||||
@@ -36,7 +37,7 @@ class GroupLayerMapper extends AbstractLayerMapper
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function getClassName(\Model $model, DefinitionMapper $mapper, Filter $filter = null)
|
protected function getClassName(Model $model, DefinitionMapper $mapper, Request $request = null)
|
||||||
{
|
{
|
||||||
if ($model->groupType === 'feature') {
|
if ($model->groupType === 'feature') {
|
||||||
return 'Netzmacht\LeafletPHP\Definition\Group\FeatureGroup';
|
return 'Netzmacht\LeafletPHP\Definition\Group\FeatureGroup';
|
||||||
@@ -50,9 +51,9 @@ class GroupLayerMapper extends AbstractLayerMapper
|
|||||||
*/
|
*/
|
||||||
protected function build(
|
protected function build(
|
||||||
Definition $definition,
|
Definition $definition,
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
if (!$definition instanceof LayerGroup) {
|
if (!$definition instanceof LayerGroup) {
|
||||||
|
|||||||
@@ -12,11 +12,11 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
||||||
|
|
||||||
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\ContaoAssets;
|
use Netzmacht\Contao\Leaflet\ContaoAssets;
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||||
use Netzmacht\Contao\Toolkit\View\Assets\AssetsManager;
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\JavascriptBuilder\Type\AnonymousFunction;
|
use Netzmacht\JavascriptBuilder\Type\AnonymousFunction;
|
||||||
use Netzmacht\JavascriptBuilder\Type\Expression;
|
use Netzmacht\JavascriptBuilder\Type\Expression;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
@@ -86,12 +86,12 @@ class MarkerClusterLayerMapper extends AbstractLayerMapper
|
|||||||
*/
|
*/
|
||||||
protected function build(
|
protected function build(
|
||||||
Definition $definition,
|
Definition $definition,
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
parent::build($definition, $model, $mapper, $filter, $parent);
|
parent::build($definition, $model, $mapper, $request, $parent);
|
||||||
|
|
||||||
/** @var MarkerClusterGroup $definition */
|
/** @var MarkerClusterGroup $definition */
|
||||||
|
|
||||||
|
|||||||
@@ -12,11 +12,12 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\GeoJsonMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\GeoJsonMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Model\MarkerModel;
|
use Netzmacht\Contao\Leaflet\Model\MarkerModel;
|
||||||
use Netzmacht\Contao\Leaflet\Frontend\RequestUrl;
|
use Netzmacht\Contao\Leaflet\Frontend\RequestUrl;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\JavascriptBuilder\Type\Expression;
|
use Netzmacht\JavascriptBuilder\Type\Expression;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Value\GeoJson\FeatureCollection;
|
use Netzmacht\LeafletPHP\Value\GeoJson\FeatureCollection;
|
||||||
@@ -39,7 +40,7 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function getClassName(\Model $model, DefinitionMapper $mapper, Filter $filter = null)
|
protected function getClassName(Model $model, DefinitionMapper $mapper, Request $request = null)
|
||||||
{
|
{
|
||||||
if ($model->deferred) {
|
if ($model->deferred) {
|
||||||
return 'Netzmacht\LeafletPHP\Plugins\Omnivore\GeoJson';
|
return 'Netzmacht\LeafletPHP\Plugins\Omnivore\GeoJson';
|
||||||
@@ -52,9 +53,9 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function buildConstructArguments(
|
protected function buildConstructArguments(
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
$elementId = null
|
$elementId = null
|
||||||
) {
|
) {
|
||||||
if ($model->deferred) {
|
if ($model->deferred) {
|
||||||
@@ -71,7 +72,7 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
|
|
||||||
return array(
|
return array(
|
||||||
$this->getElementId($model, $elementId),
|
$this->getElementId($model, $elementId),
|
||||||
RequestUrl::create($model->id, null, null, $filter),
|
RequestUrl::create($model->id, null, null, $request),
|
||||||
array(),
|
array(),
|
||||||
$layer
|
$layer
|
||||||
);
|
);
|
||||||
@@ -79,11 +80,11 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
|
|
||||||
return array(
|
return array(
|
||||||
$this->getElementId($model, $elementId),
|
$this->getElementId($model, $elementId),
|
||||||
RequestUrl::create($model->id, null, null, $filter)
|
RequestUrl::create($model->id, null, null, $request)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::buildConstructArguments($model, $mapper, $filter, $elementId);
|
return parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,9 +92,9 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
*/
|
*/
|
||||||
protected function build(
|
protected function build(
|
||||||
Definition $definition,
|
Definition $definition,
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
if ($definition instanceof GeoJson) {
|
if ($definition instanceof GeoJson) {
|
||||||
@@ -123,10 +124,10 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function handleGeoJson(\Model $model, DefinitionMapper $mapper, Filter $filter = null)
|
public function handleGeoJson(Model $model, DefinitionMapper $mapper, Request $request = null)
|
||||||
{
|
{
|
||||||
$feature = new FeatureCollection();
|
$feature = new FeatureCollection();
|
||||||
$collection = $this->loadMarkerModels($model, $filter);
|
$collection = $this->loadMarkerModels($model, $request);
|
||||||
|
|
||||||
if ($collection) {
|
if ($collection) {
|
||||||
foreach ($collection as $item) {
|
foreach ($collection as $item) {
|
||||||
@@ -145,15 +146,15 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
/**
|
/**
|
||||||
* Load all layer markers.
|
* Load all layer markers.
|
||||||
*
|
*
|
||||||
* @param \Model $model The layer model.
|
* @param Model $model The layer model.
|
||||||
* @param Filter $filter The request filter.
|
* @param Request $request Optional building request.
|
||||||
*
|
*
|
||||||
* @return \Model\Collection|null
|
* @return \Model\Collection|null
|
||||||
*/
|
*/
|
||||||
protected function loadMarkerModels(\Model $model, Filter $filter = null)
|
protected function loadMarkerModels(Model $model, Request $request = null)
|
||||||
{
|
{
|
||||||
if ($model->boundsMode == 'fit') {
|
if ($model->boundsMode == 'fit') {
|
||||||
return MarkerModel::findByFilter($model->id, $filter);
|
return MarkerModel::findByFilter($model->id, $request->getFilter());
|
||||||
}
|
}
|
||||||
|
|
||||||
return MarkerModel::findByFilter($model->id);
|
return MarkerModel::findByFilter($model->id);
|
||||||
|
|||||||
@@ -12,11 +12,11 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
||||||
|
|
||||||
use Model;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Definition\Layer\OverpassLayer;
|
use Netzmacht\Contao\Leaflet\Definition\Layer\OverpassLayer;
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\JavascriptBuilder\Type\Expression;
|
use Netzmacht\JavascriptBuilder\Type\Expression;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ class OverpassLayerMapper extends AbstractLayerMapper
|
|||||||
Definition $definition,
|
Definition $definition,
|
||||||
Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
if (!$definition instanceof OverpassLayer) {
|
if (!$definition instanceof OverpassLayer) {
|
||||||
|
|||||||
@@ -12,9 +12,10 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\OptionsBuilder;
|
use Netzmacht\Contao\Leaflet\Mapper\OptionsBuilder;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,7 +54,7 @@ class ProviderLayerMapper extends AbstractLayerMapper
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function getClassName(\Model $model, DefinitionMapper $mapper, Filter $filter = null)
|
protected function getClassName(Model $model, DefinitionMapper $mapper, Request $request = null)
|
||||||
{
|
{
|
||||||
if (isset($this->providers[$model->tile_provider]['class'])) {
|
if (isset($this->providers[$model->tile_provider]['class'])) {
|
||||||
return $this->providers[$model->tile_provider]['class'];
|
return $this->providers[$model->tile_provider]['class'];
|
||||||
@@ -67,9 +68,9 @@ class ProviderLayerMapper extends AbstractLayerMapper
|
|||||||
*/
|
*/
|
||||||
protected function build(
|
protected function build(
|
||||||
Definition $definition,
|
Definition $definition,
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
if (!empty($this->providers[$model->tile_provider]['options'])) {
|
if (!empty($this->providers[$model->tile_provider]['options'])) {
|
||||||
@@ -85,9 +86,9 @@ class ProviderLayerMapper extends AbstractLayerMapper
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function buildConstructArguments(
|
protected function buildConstructArguments(
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
$elementId = null
|
$elementId = null
|
||||||
) {
|
) {
|
||||||
return array(
|
return array(
|
||||||
|
|||||||
@@ -12,9 +12,9 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
use Netzmacht\Contao\Leaflet\Model\LayerModel;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,7 +37,7 @@ class ReferenceLayerMapper extends AbstractLayerMapper
|
|||||||
public function handle(
|
public function handle(
|
||||||
$model,
|
$model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
$elementId = null,
|
$elementId = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
@@ -49,6 +49,6 @@ class ReferenceLayerMapper extends AbstractLayerMapper
|
|||||||
|
|
||||||
$elementId = $model->standalone ? $this->getElementId($model, $elementId) : null;
|
$elementId = $model->standalone ? $this->getElementId($model, $elementId) : null;
|
||||||
|
|
||||||
return $mapper->handle($reference, $filter, $elementId);
|
return $mapper->handle($reference, $request, $elementId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,10 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
|
use Contao\StringUtil;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Raster\TileLayer;
|
use Netzmacht\LeafletPHP\Definition\Raster\TileLayer;
|
||||||
use Netzmacht\LeafletPHP\Value\LatLngBounds;
|
use Netzmacht\LeafletPHP\Value\LatLngBounds;
|
||||||
@@ -64,12 +66,12 @@ class TileLayerMapper extends AbstractLayerMapper
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function buildConstructArguments(
|
protected function buildConstructArguments(
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
$elementId = null
|
$elementId = null
|
||||||
) {
|
) {
|
||||||
$arguments = parent::buildConstructArguments($model, $mapper, $filter, $elementId);
|
$arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
||||||
|
|
||||||
$arguments[] = $model->tileUrl;
|
$arguments[] = $model->tileUrl;
|
||||||
|
|
||||||
@@ -81,26 +83,26 @@ class TileLayerMapper extends AbstractLayerMapper
|
|||||||
*/
|
*/
|
||||||
protected function build(
|
protected function build(
|
||||||
Definition $definition,
|
Definition $definition,
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
parent::build($definition, $model, $mapper, $filter, $parent);
|
parent::build($definition, $model, $mapper, $request, $parent);
|
||||||
|
|
||||||
/** @var TileLayer $definition */
|
/** @var TileLayer $definition */
|
||||||
$filter = deserialize($model->bounds);
|
$bounds = StringUtil::deserialize($model->bounds);
|
||||||
|
|
||||||
if ($filter[0] && $filter[1]) {
|
if ($request[0] && $request[1]) {
|
||||||
$filter = array_map(
|
$bounds = array_map(
|
||||||
function ($value) {
|
function ($value) {
|
||||||
return explode(',', $value, 3);
|
return explode(',', $value, 3);
|
||||||
},
|
},
|
||||||
$filter
|
$bounds
|
||||||
);
|
);
|
||||||
|
|
||||||
$filter = LatLngBounds::fromArray($filter);
|
$bounds = LatLngBounds::fromArray($bounds);
|
||||||
$definition->setBounds($filter);
|
$definition->setBounds($bounds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,16 +12,17 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
|
use Contao\Model\Collection;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\GeoJsonMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\GeoJsonMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Model\VectorModel;
|
use Netzmacht\Contao\Leaflet\Model\VectorModel;
|
||||||
use Netzmacht\Contao\Leaflet\Frontend\RequestUrl;
|
use Netzmacht\Contao\Leaflet\Frontend\RequestUrl;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\JavascriptBuilder\Type\Expression;
|
use Netzmacht\JavascriptBuilder\Type\Expression;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Value\GeoJson\FeatureCollection;
|
use Netzmacht\LeafletPHP\Value\GeoJson\FeatureCollection;
|
||||||
use Netzmacht\LeafletPHP\Definition\Group\GeoJson;
|
use Netzmacht\LeafletPHP\Definition\Group\GeoJson;
|
||||||
use Netzmacht\LeafletPHP\Definition\Vector;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class VectorsLayerMapper maps the layer model for the Vectors layer definition.
|
* Class VectorsLayerMapper maps the layer model for the Vectors layer definition.
|
||||||
@@ -40,7 +41,7 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function getClassName(\Model $model, DefinitionMapper $mapper, Filter $filter = null)
|
protected function getClassName(Model $model, DefinitionMapper $mapper, Request $request = null)
|
||||||
{
|
{
|
||||||
if ($model->deferred) {
|
if ($model->deferred) {
|
||||||
return 'Netzmacht\LeafletPHP\Plugins\Omnivore\GeoJson';
|
return 'Netzmacht\LeafletPHP\Plugins\Omnivore\GeoJson';
|
||||||
@@ -53,9 +54,9 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function buildConstructArguments(
|
protected function buildConstructArguments(
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
$elementId = null
|
$elementId = null
|
||||||
) {
|
) {
|
||||||
if ($model->deferred) {
|
if ($model->deferred) {
|
||||||
@@ -79,7 +80,7 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
|
|
||||||
return array(
|
return array(
|
||||||
$this->getElementId($model, $elementId),
|
$this->getElementId($model, $elementId),
|
||||||
RequestUrl::create($model->id, null, null, $filter),
|
RequestUrl::create($model->id, null, null, $request),
|
||||||
array(),
|
array(),
|
||||||
$layer
|
$layer
|
||||||
);
|
);
|
||||||
@@ -87,11 +88,11 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
|
|
||||||
return array(
|
return array(
|
||||||
$this->getElementId($model, $elementId),
|
$this->getElementId($model, $elementId),
|
||||||
RequestUrl::create($model->id, null, null, $filter)
|
RequestUrl::create($model->id, null, null, $request)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::buildConstructArguments($model, $mapper, $filter, $elementId);
|
return parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,9 +100,9 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
*/
|
*/
|
||||||
protected function build(
|
protected function build(
|
||||||
Definition $definition,
|
Definition $definition,
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
if ($definition instanceof GeoJson) {
|
if ($definition instanceof GeoJson) {
|
||||||
@@ -129,7 +130,7 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function handleGeoJson(\Model $model, DefinitionMapper $mapper, Filter $filter = null)
|
public function handleGeoJson(Model $model, DefinitionMapper $mapper, Request $request = null)
|
||||||
{
|
{
|
||||||
$definition = new FeatureCollection();
|
$definition = new FeatureCollection();
|
||||||
$collection = $this->loadVectorModels($model);
|
$collection = $this->loadVectorModels($model);
|
||||||
@@ -151,13 +152,13 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
/**
|
/**
|
||||||
* Load vector models.
|
* Load vector models.
|
||||||
*
|
*
|
||||||
* @param \Model $model The layer model.
|
* @param Model $model The layer model.
|
||||||
*
|
*
|
||||||
* @return \Model\Collection|null
|
* @return Collection|null
|
||||||
*/
|
*/
|
||||||
protected function loadVectorModels(\Model $model)
|
protected function loadVectorModels(Model $model)
|
||||||
{
|
{
|
||||||
return VectorModel::findActiveBy('pid', $model->id, array('order' => 'sorting'));
|
return VectorModel::findActiveBy('pid', $model->id, ['order' => 'sorting']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -12,10 +12,10 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper;
|
namespace Netzmacht\Contao\Leaflet\Mapper;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Model\ControlModel;
|
use Netzmacht\Contao\Leaflet\Model\ControlModel;
|
||||||
use Netzmacht\Contao\Leaflet\Model\MapModel;
|
use Netzmacht\Contao\Leaflet\Model\MapModel;
|
||||||
use Netzmacht\JavascriptBuilder\Type\Expression;
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Control;
|
use Netzmacht\LeafletPHP\Definition\Control;
|
||||||
use Netzmacht\LeafletPHP\Definition\Layer;
|
use Netzmacht\LeafletPHP\Definition\Layer;
|
||||||
@@ -60,15 +60,15 @@ class MapMapper extends AbstractMapper
|
|||||||
*/
|
*/
|
||||||
protected function build(
|
protected function build(
|
||||||
Definition $map,
|
Definition $map,
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
if ($map instanceof Map && $model instanceof MapModel) {
|
if ($map instanceof Map && $model instanceof MapModel) {
|
||||||
$this->buildCustomOptions($map, $model);
|
$this->buildCustomOptions($map, $model);
|
||||||
$this->buildControls($map, $model, $mapper, $filter);
|
$this->buildControls($map, $model, $mapper, $request);
|
||||||
$this->buildLayers($map, $model, $mapper, $filter);
|
$this->buildLayers($map, $model, $mapper, $request);
|
||||||
$this->buildBoundsCalculation($map, $model);
|
$this->buildBoundsCalculation($map, $model);
|
||||||
$this->buildLocate($map, $model);
|
$this->buildLocate($map, $model);
|
||||||
}
|
}
|
||||||
@@ -78,9 +78,9 @@ class MapMapper extends AbstractMapper
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function buildConstructArguments(
|
protected function buildConstructArguments(
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
$elementId = null
|
$elementId = null
|
||||||
) {
|
) {
|
||||||
return array(
|
return array(
|
||||||
@@ -113,14 +113,14 @@ class MapMapper extends AbstractMapper
|
|||||||
/**
|
/**
|
||||||
* Build map controls.
|
* Build map controls.
|
||||||
*
|
*
|
||||||
* @param Map $map The map being built.
|
* @param Map $map The map being built.
|
||||||
* @param MapModel $model The map model.
|
* @param MapModel $model The map model.
|
||||||
* @param DefinitionMapper $mapper The definition mapper.
|
* @param DefinitionMapper $mapper The definition mapper.
|
||||||
* @param Filter $filter Optional request filter.
|
* @param Request $request Optional building request.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function buildControls(Map $map, MapModel $model, DefinitionMapper $mapper, Filter $filter = null)
|
private function buildControls(Map $map, MapModel $model, DefinitionMapper $mapper, Request $request = null)
|
||||||
{
|
{
|
||||||
$collection = ControlModel::findActiveBy('pid', $model->id, array('order' => 'sorting'));
|
$collection = ControlModel::findActiveBy('pid', $model->id, array('order' => 'sorting'));
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ class MapMapper extends AbstractMapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($collection as $control) {
|
foreach ($collection as $control) {
|
||||||
$control = $mapper->handle($control, $filter, null, $map);
|
$control = $mapper->handle($control, $request, null, $map);
|
||||||
|
|
||||||
if ($control instanceof Control) {
|
if ($control instanceof Control) {
|
||||||
$control->addTo($map);
|
$control->addTo($map);
|
||||||
@@ -140,14 +140,14 @@ class MapMapper extends AbstractMapper
|
|||||||
/**
|
/**
|
||||||
* Build map layers.
|
* Build map layers.
|
||||||
*
|
*
|
||||||
* @param Map $map The map being built.
|
* @param Map $map The map being built.
|
||||||
* @param MapModel $model The map model.
|
* @param MapModel $model The map model.
|
||||||
* @param DefinitionMapper $mapper Definition mapper.
|
* @param DefinitionMapper $mapper Definition mapper.
|
||||||
* @param Filter $filter Optional request filter.
|
* @param Request $request Optional building request.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function buildLayers(Map $map, MapModel $model, DefinitionMapper $mapper, Filter $filter = null)
|
private function buildLayers(Map $map, MapModel $model, DefinitionMapper $mapper, Request $request = null)
|
||||||
{
|
{
|
||||||
$collection = $model->findActiveLayers();
|
$collection = $model->findActiveLayers();
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ class MapMapper extends AbstractMapper
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$layer = $mapper->handle($layer, $filter, null, $map);
|
$layer = $mapper->handle($layer, $request, null, $map);
|
||||||
if ($layer instanceof Layer) {
|
if ($layer instanceof Layer) {
|
||||||
$layer->addTo($map);
|
$layer->addTo($map);
|
||||||
}
|
}
|
||||||
@@ -197,7 +197,6 @@ class MapMapper extends AbstractMapper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build map bounds calculations.
|
* Build map bounds calculations.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper;
|
namespace Netzmacht\Contao\Leaflet\Mapper;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,9 +26,9 @@ interface Mapper
|
|||||||
/**
|
/**
|
||||||
* Map model to the definition.
|
* Map model to the definition.
|
||||||
*
|
*
|
||||||
* @param \Model|mixed $model The model being built. Usually a contao model, but can be anything.
|
* @param Model|mixed $model The model being built. Usually a contao model, but can be anything.
|
||||||
* @param DefinitionMapper $mapper The definition builder.
|
* @param DefinitionMapper $mapper The definition builder.
|
||||||
* @param Filter $filter Optional filter bounds.
|
* @param Request $request Optional building request.
|
||||||
* @param string $elementId Optional element.
|
* @param string $elementId Optional element.
|
||||||
* @param Definition|null $parent Optional passed parent.
|
* @param Definition|null $parent Optional passed parent.
|
||||||
*
|
*
|
||||||
@@ -36,7 +37,7 @@ interface Mapper
|
|||||||
public function handle(
|
public function handle(
|
||||||
$model,
|
$model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
$elementId = null,
|
$elementId = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
);
|
);
|
||||||
@@ -44,10 +45,10 @@ interface Mapper
|
|||||||
/**
|
/**
|
||||||
* Check if mapper is responsible for the model.
|
* Check if mapper is responsible for the model.
|
||||||
*
|
*
|
||||||
* @param \Model $model The model being build.
|
* @param Model $model The model being build.
|
||||||
* @param Filter $filter Optional filter bounds.
|
* @param Request $request Optional building request.
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function match($model, Filter $filter = null);
|
public function match($model, Request $request = null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper;
|
namespace Netzmacht\Contao\Leaflet\Mapper;
|
||||||
|
|
||||||
|
use Contao\Model;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\HasOptions;
|
use Netzmacht\LeafletPHP\Definition\HasOptions;
|
||||||
|
|
||||||
@@ -199,7 +200,7 @@ class OptionsBuilder
|
|||||||
*
|
*
|
||||||
* @param array $options The options.
|
* @param array $options The options.
|
||||||
* @param Definition $definition The definition being built.
|
* @param Definition $definition The definition being built.
|
||||||
* @param \Model $model The model.
|
* @param Model $model The model.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
* @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE
|
* @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Style;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Style;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -12,8 +12,9 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Type;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Type;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Type\DivIcon;
|
use Netzmacht\LeafletPHP\Definition\Type\DivIcon;
|
||||||
|
|
||||||
@@ -53,12 +54,12 @@ class DivIconMapper extends AbstractIconMapper
|
|||||||
*/
|
*/
|
||||||
protected function build(
|
protected function build(
|
||||||
Definition $definition,
|
Definition $definition,
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
parent::build($definition, $model, $mapper, $filter);
|
parent::build($definition, $model, $mapper, $request);
|
||||||
|
|
||||||
if ($definition instanceof DivIcon && $model->iconSize) {
|
if ($definition instanceof DivIcon && $model->iconSize) {
|
||||||
$definition->setIconSize(explode(',', $model->iconSize, 2));
|
$definition->setIconSize(explode(',', $model->iconSize, 2));
|
||||||
|
|||||||
@@ -12,8 +12,9 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Type;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Type;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Type\DivIcon;
|
use Netzmacht\LeafletPHP\Definition\Type\DivIcon;
|
||||||
|
|
||||||
@@ -53,12 +54,12 @@ class ExtraMarkersIconMapper extends AbstractIconMapper
|
|||||||
*/
|
*/
|
||||||
protected function build(
|
protected function build(
|
||||||
Definition $definition,
|
Definition $definition,
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
parent::build($definition, $model, $mapper, $filter);
|
parent::build($definition, $model, $mapper, $request);
|
||||||
|
|
||||||
if ($definition instanceof DivIcon && $model->iconSize) {
|
if ($definition instanceof DivIcon && $model->iconSize) {
|
||||||
$definition->setIconSize(explode(',', $model->iconSize, 2));
|
$definition->setIconSize(explode(',', $model->iconSize, 2));
|
||||||
|
|||||||
@@ -12,9 +12,10 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Type;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Type;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Type\ImageIcon;
|
use Netzmacht\LeafletPHP\Definition\Type\ImageIcon;
|
||||||
|
|
||||||
@@ -43,12 +44,12 @@ class ImageIconMapper extends AbstractIconMapper
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function buildConstructArguments(
|
protected function buildConstructArguments(
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
$elementId = null
|
$elementId = null
|
||||||
) {
|
) {
|
||||||
$arguments = parent::buildConstructArguments($model, $mapper, $filter, $elementId);
|
$arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
||||||
|
|
||||||
if ($model->iconImage) {
|
if ($model->iconImage) {
|
||||||
$file = \FilesModel::findByUuid($model->iconImage);
|
$file = \FilesModel::findByUuid($model->iconImage);
|
||||||
@@ -66,9 +67,9 @@ class ImageIconMapper extends AbstractIconMapper
|
|||||||
*/
|
*/
|
||||||
protected function build(
|
protected function build(
|
||||||
Definition $definition,
|
Definition $definition,
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
if ($definition instanceof ImageIcon) {
|
if ($definition instanceof ImageIcon) {
|
||||||
|
|||||||
@@ -12,12 +12,13 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\UI;
|
namespace Netzmacht\Contao\Leaflet\Mapper\UI;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Frontend\ValueFilter;
|
use Netzmacht\Contao\Leaflet\Frontend\ValueFilter;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\AbstractMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\AbstractMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
||||||
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Type\ImageIcon;
|
use Netzmacht\LeafletPHP\Definition\Type\ImageIcon;
|
||||||
use Netzmacht\LeafletPHP\Definition\UI\Marker;
|
use Netzmacht\LeafletPHP\Definition\UI\Marker;
|
||||||
@@ -67,12 +68,12 @@ class MarkerMapper extends AbstractMapper
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function buildConstructArguments(
|
protected function buildConstructArguments(
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
$elementId = null
|
$elementId = null
|
||||||
) {
|
) {
|
||||||
$arguments = parent::buildConstructArguments($model, $mapper, $filter, $elementId);
|
$arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
||||||
$arguments[] = array($model->latitude, $model->longitude, $model->altitude ?: null) ?: null;
|
$arguments[] = array($model->latitude, $model->longitude, $model->altitude ?: null) ?: null;
|
||||||
|
|
||||||
return $arguments;
|
return $arguments;
|
||||||
@@ -95,9 +96,9 @@ class MarkerMapper extends AbstractMapper
|
|||||||
*/
|
*/
|
||||||
protected function build(
|
protected function build(
|
||||||
Definition $definition,
|
Definition $definition,
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
if ($definition instanceof Marker) {
|
if ($definition instanceof Marker) {
|
||||||
@@ -109,7 +110,7 @@ class MarkerMapper extends AbstractMapper
|
|||||||
$popupModel = PopupModel::findActiveByPK($model->popup);
|
$popupModel = PopupModel::findActiveByPK($model->popup);
|
||||||
|
|
||||||
if ($popupModel) {
|
if ($popupModel) {
|
||||||
$popup = $mapper->handle($popupModel, $filter, null, $definition);
|
$popup = $mapper->handle($popupModel, $request, null, $definition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,11 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\UI;
|
namespace Netzmacht\Contao\Leaflet\Mapper\UI;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\AbstractMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\AbstractMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\UI\Popup;
|
use Netzmacht\LeafletPHP\Definition\UI\Popup;
|
||||||
|
|
||||||
@@ -60,12 +61,12 @@ class PopupMapper extends AbstractMapper
|
|||||||
*/
|
*/
|
||||||
protected function build(
|
protected function build(
|
||||||
Definition $definition,
|
Definition $definition,
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
parent::build($definition, $model, $mapper, $filter, $parent);
|
parent::build($definition, $model, $mapper, $request, $parent);
|
||||||
|
|
||||||
/** @var Popup $definition */
|
/** @var Popup $definition */
|
||||||
/** @var PopupModel $model */
|
/** @var PopupModel $model */
|
||||||
|
|||||||
@@ -12,13 +12,14 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
||||||
|
|
||||||
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Definition\Style;
|
use Netzmacht\Contao\Leaflet\Definition\Style;
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
|
||||||
use Netzmacht\Contao\Leaflet\Frontend\ValueFilter;
|
use Netzmacht\Contao\Leaflet\Frontend\ValueFilter;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
use Netzmacht\Contao\Leaflet\Model\PopupModel;
|
||||||
use Netzmacht\Contao\Leaflet\Model\StyleModel;
|
use Netzmacht\Contao\Leaflet\Model\StyleModel;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\HasPopup;
|
use Netzmacht\LeafletPHP\Definition\HasPopup;
|
||||||
use Netzmacht\LeafletPHP\Definition\UI\Popup;
|
use Netzmacht\LeafletPHP\Definition\UI\Popup;
|
||||||
@@ -62,12 +63,12 @@ class AbstractVectorMapper extends AbstractTypeMapper
|
|||||||
*/
|
*/
|
||||||
protected function build(
|
protected function build(
|
||||||
Definition $definition,
|
Definition $definition,
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
parent::build($definition, $model, $mapper, $filter);
|
parent::build($definition, $model, $mapper, $request);
|
||||||
|
|
||||||
if ($definition instanceof Path && $model->style) {
|
if ($definition instanceof Path && $model->style) {
|
||||||
$styleModel = StyleModel::findActiveByPK($model->style);
|
$styleModel = StyleModel::findActiveByPK($model->style);
|
||||||
@@ -81,24 +82,24 @@ class AbstractVectorMapper extends AbstractTypeMapper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->buildPopup($definition, $model, $mapper, $filter);
|
$this->buildPopup($definition, $model, $mapper, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the popup.
|
* Build the popup.
|
||||||
*
|
*
|
||||||
* @param Definition $definition The definition.
|
* @param Definition $definition The definition.
|
||||||
* @param \Model $model The model.
|
* @param Model $model The model.
|
||||||
* @param DefinitionMapper $mapper The definition mapper.
|
* @param DefinitionMapper $mapper The definition mapper.
|
||||||
* @param Filter $filter The filter.
|
* @param Request $request Optional building request.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function buildPopup(
|
protected function buildPopup(
|
||||||
Definition $definition,
|
Definition $definition,
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null
|
Request $request = null
|
||||||
) {
|
) {
|
||||||
if ($definition instanceof HasPopup && $model->addPopup) {
|
if ($definition instanceof HasPopup && $model->addPopup) {
|
||||||
$popup = null;
|
$popup = null;
|
||||||
@@ -108,7 +109,7 @@ class AbstractVectorMapper extends AbstractTypeMapper
|
|||||||
$popupModel = PopupModel::findActiveByPK($model->popup);
|
$popupModel = PopupModel::findActiveByPK($model->popup);
|
||||||
|
|
||||||
if ($popupModel) {
|
if ($popupModel) {
|
||||||
$popup = $mapper->handle($popupModel, $filter, null, $definition);
|
$popup = $mapper->handle($popupModel, $request, null, $definition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,12 +12,12 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Vector\CircleMarker;
|
use Netzmacht\LeafletPHP\Definition\Vector\CircleMarker;
|
||||||
use Netzmacht\LeafletPHP\Value\LatLng;
|
use Netzmacht\LeafletPHP\Value\LatLng;
|
||||||
use Netzmacht\LeafletPHP\Definition\Vector\Circle;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CircleMapper maps the database model to the circle definition.
|
* Class CircleMapper maps the database model to the circle definition.
|
||||||
@@ -55,12 +55,12 @@ class CircleMapper extends AbstractVectorMapper
|
|||||||
*/
|
*/
|
||||||
protected function build(
|
protected function build(
|
||||||
Definition $definition,
|
Definition $definition,
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
parent::build($definition, $model, $mapper, $filter);
|
parent::build($definition, $model, $mapper, $request);
|
||||||
|
|
||||||
if ($definition instanceof CircleMarker) {
|
if ($definition instanceof CircleMarker) {
|
||||||
$definition->setLatLng(LatLng::fromString($model->coordinates));
|
$definition->setLatLng(LatLng::fromString($model->coordinates));
|
||||||
|
|||||||
@@ -12,8 +12,9 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Vector\Polygon;
|
use Netzmacht\LeafletPHP\Definition\Vector\Polygon;
|
||||||
|
|
||||||
@@ -43,12 +44,12 @@ class MultiPolygonMapper extends MultiPolylineMapper
|
|||||||
*/
|
*/
|
||||||
protected function build(
|
protected function build(
|
||||||
Definition $definition,
|
Definition $definition,
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
parent::build($definition, $model, $mapper, $filter);
|
parent::build($definition, $model, $mapper, $request);
|
||||||
|
|
||||||
if ($definition instanceof Polygon) {
|
if ($definition instanceof Polygon) {
|
||||||
$this->createLatLngs($definition, $model);
|
$this->createLatLngs($definition, $model);
|
||||||
|
|||||||
@@ -12,8 +12,9 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\Vector\Polyline;
|
use Netzmacht\LeafletPHP\Definition\Vector\Polyline;
|
||||||
use Netzmacht\LeafletPHP\Value\LatLng;
|
use Netzmacht\LeafletPHP\Value\LatLng;
|
||||||
@@ -44,12 +45,12 @@ class MultiPolylineMapper extends AbstractVectorMapper
|
|||||||
*/
|
*/
|
||||||
protected function build(
|
protected function build(
|
||||||
Definition $definition,
|
Definition $definition,
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
parent::build($definition, $model, $mapper, $filter);
|
parent::build($definition, $model, $mapper, $request);
|
||||||
|
|
||||||
if ($definition instanceof Polyline) {
|
if ($definition instanceof Polyline) {
|
||||||
$this->createLatLngs($definition, $model);
|
$this->createLatLngs($definition, $model);
|
||||||
@@ -60,11 +61,11 @@ class MultiPolylineMapper extends AbstractVectorMapper
|
|||||||
* Create lat lngs for the definition.
|
* Create lat lngs for the definition.
|
||||||
*
|
*
|
||||||
* @param Polyline $definition The multi polyline.
|
* @param Polyline $definition The multi polyline.
|
||||||
* @param \Model $model The definition model.
|
* @param Model $model The definition model.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function createLatLngs(Polyline $definition, \Model $model)
|
protected function createLatLngs(Polyline $definition, Model $model)
|
||||||
{
|
{
|
||||||
foreach (deserialize($model->multiData, true) as $ring => $data) {
|
foreach (deserialize($model->multiData, true) as $ring => $data) {
|
||||||
$latLngs = array_map(
|
$latLngs = array_map(
|
||||||
|
|||||||
@@ -12,8 +12,9 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Value\LatLng;
|
use Netzmacht\LeafletPHP\Value\LatLng;
|
||||||
use Netzmacht\LeafletPHP\Definition\Vector\Polyline;
|
use Netzmacht\LeafletPHP\Definition\Vector\Polyline;
|
||||||
@@ -44,12 +45,12 @@ class PolylineMapper extends AbstractVectorMapper
|
|||||||
*/
|
*/
|
||||||
protected function build(
|
protected function build(
|
||||||
Definition $definition,
|
Definition $definition,
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
Definition $parent = null
|
Definition $parent = null
|
||||||
) {
|
) {
|
||||||
parent::build($definition, $model, $mapper, $filter);
|
parent::build($definition, $model, $mapper, $request);
|
||||||
|
|
||||||
if ($definition instanceof Polyline) {
|
if ($definition instanceof Polyline) {
|
||||||
array_map(
|
array_map(
|
||||||
|
|||||||
@@ -12,9 +12,9 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
||||||
|
|
||||||
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
use Contao\Model;
|
||||||
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\Contao\Leaflet\Request\Request;
|
||||||
use Netzmacht\LeafletPHP\Value\LatLng;
|
use Netzmacht\LeafletPHP\Value\LatLng;
|
||||||
use Netzmacht\LeafletPHP\Value\LatLngBounds;
|
use Netzmacht\LeafletPHP\Value\LatLngBounds;
|
||||||
|
|
||||||
@@ -43,9 +43,9 @@ class RectangleMapper extends AbstractVectorMapper
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function buildConstructArguments(
|
protected function buildConstructArguments(
|
||||||
\Model $model,
|
Model $model,
|
||||||
DefinitionMapper $mapper,
|
DefinitionMapper $mapper,
|
||||||
Filter $filter = null,
|
Request $request = null,
|
||||||
$elementId = null
|
$elementId = null
|
||||||
) {
|
) {
|
||||||
$latLngs = array_map(
|
$latLngs = array_map(
|
||||||
@@ -55,7 +55,7 @@ class RectangleMapper extends AbstractVectorMapper
|
|||||||
deserialize($model->bounds, true)
|
deserialize($model->bounds, true)
|
||||||
);
|
);
|
||||||
|
|
||||||
$arguments = parent::buildConstructArguments($model, $mapper, $filter, $elementId);
|
$arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
||||||
$arguments[] = new LatLngBounds($latLngs[0], $latLngs[1]);
|
$arguments[] = new LatLngBounds($latLngs[0], $latLngs[1]);
|
||||||
|
|
||||||
return $arguments;
|
return $arguments;
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Model;
|
namespace Netzmacht\Contao\Leaflet\Model;
|
||||||
|
|
||||||
|
use Contao\Model\Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AbstractActiveModel is the base model for models with an active field.
|
* Class AbstractActiveModel is the base model for models with an active field.
|
||||||
*
|
*
|
||||||
@@ -39,7 +41,7 @@ abstract class AbstractActiveModel extends \Model
|
|||||||
* @param mixed $value The column value.
|
* @param mixed $value The column value.
|
||||||
* @param array $options The options.
|
* @param array $options The options.
|
||||||
*
|
*
|
||||||
* @return \Model|null
|
* @return Collection|null
|
||||||
*/
|
*/
|
||||||
public static function findActiveBy($column, $value, $options = array())
|
public static function findActiveBy($column, $value, $options = array())
|
||||||
{
|
{
|
||||||
@@ -57,7 +59,7 @@ abstract class AbstractActiveModel extends \Model
|
|||||||
*
|
*
|
||||||
* @param array $options The query options.
|
* @param array $options The query options.
|
||||||
*
|
*
|
||||||
* @return \Model\Collection|null
|
* @return Collection|null
|
||||||
*/
|
*/
|
||||||
public static function findActives($options = array())
|
public static function findActives($options = array())
|
||||||
{
|
{
|
||||||
|
|||||||
71
src/Request/Request.php
Normal file
71
src/Request/Request.php
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Leaflet maps for Contao CMS.
|
||||||
|
*
|
||||||
|
* @package contao-leaflet-maps
|
||||||
|
* @author David Molineus <david.molineus@netzmacht.de>
|
||||||
|
* @copyright 2016-2017 netzmacht David Molineus. All rights reserved.
|
||||||
|
* @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE
|
||||||
|
* @filesource
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Netzmacht\Contao\Leaflet\Request;
|
||||||
|
|
||||||
|
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class MapRequest
|
||||||
|
*
|
||||||
|
* @package Netzmacht\Contao\Leaflet\Request
|
||||||
|
*/
|
||||||
|
class Request
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Map identifier.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $identifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request filter.
|
||||||
|
*
|
||||||
|
* @var Filter|null
|
||||||
|
*/
|
||||||
|
private $filter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request constructor.
|
||||||
|
*
|
||||||
|
* @param string $identifier Map identifier.
|
||||||
|
* @param Filter|null $filter Filter.
|
||||||
|
*/
|
||||||
|
public function __construct($identifier, Filter $filter = null)
|
||||||
|
{
|
||||||
|
$this->identifier = $identifier;
|
||||||
|
$this->filter = $filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the map identifier.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getMapIdentifier(): string
|
||||||
|
{
|
||||||
|
return $this->identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the filter.
|
||||||
|
*
|
||||||
|
* @return Filter|null
|
||||||
|
*/
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user