forked from Snck3rs/contao-leaflet-maps
Extract request url.
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
"contao/core":">=3.1,<3.5-dev",
|
"contao/core":">=3.1,<3.5-dev",
|
||||||
"contao-community-alliance/dependency-container":"~1.0",
|
"contao-community-alliance/dependency-container":"~1.0",
|
||||||
"contao-community-alliance/event-dispatcher":"~1.0",
|
"contao-community-alliance/event-dispatcher":"~1.0",
|
||||||
|
"contao-community-alliance/url-builder":"~1.1",
|
||||||
"netzmacht/php-javascript-builder": "~1.0",
|
"netzmacht/php-javascript-builder": "~1.0",
|
||||||
"netzmacht/php-leaflet": "dev-master",
|
"netzmacht/php-leaflet": "dev-master",
|
||||||
"bit3/contao-meta-palettes": "~1.5",
|
"bit3/contao-meta-palettes": "~1.5",
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Layer;
|
|||||||
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\Request\RequestUrl;
|
||||||
use Netzmacht\Javascript\Type\Value\Reference;
|
use Netzmacht\Javascript\Type\Value\Reference;
|
||||||
use Netzmacht\LeafletPHP\Definition;
|
use Netzmacht\LeafletPHP\Definition;
|
||||||
use Netzmacht\LeafletPHP\Definition\GeoJson\FeatureCollection;
|
use Netzmacht\LeafletPHP\Definition\GeoJson\FeatureCollection;
|
||||||
@@ -63,8 +64,7 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
|||||||
LatLngBounds $bounds = null
|
LatLngBounds $bounds = null
|
||||||
) {
|
) {
|
||||||
if ($definition instanceof GeoJsonAjax) {
|
if ($definition instanceof GeoJsonAjax) {
|
||||||
$base = \Config::get('websitePath') . '/assets/leaflet/geojson.php?id=';
|
$definition->setUrl(RequestUrl::create($model->id));
|
||||||
$definition->setUrl($base . $model->id);
|
|
||||||
} elseif ($definition instanceof LayerGroup) {
|
} elseif ($definition instanceof LayerGroup) {
|
||||||
$collection = $this->loadMarkerModels($model);
|
$collection = $this->loadMarkerModels($model);
|
||||||
|
|
||||||
|
|||||||
60
src/Netzmacht/Contao/Leaflet/Request/RequestUrl.php
Normal file
60
src/Netzmacht/Contao/Leaflet/Request/RequestUrl.php
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @package dev
|
||||||
|
* @author David Molineus <david.molineus@netzmacht.de>
|
||||||
|
* @copyright 2015 netzmacht creative David Molineus
|
||||||
|
* @license LGPL 3.0
|
||||||
|
* @filesource
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Netzmacht\Contao\Leaflet\Request;
|
||||||
|
|
||||||
|
use ContaoCommunityAlliance\UrlBuilder\UrlBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class RequestUrl creates the request url.
|
||||||
|
*
|
||||||
|
* @package Netzmacht\Contao\Leaflet\Request
|
||||||
|
*/
|
||||||
|
class RequestUrl
|
||||||
|
{
|
||||||
|
const BASE = 'assets/leaflet/data.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the request url.
|
||||||
|
*
|
||||||
|
* @param int $id Object id.
|
||||||
|
* @param string|null $type Object type. If empty it assumes a layer.
|
||||||
|
* @param string|null $format Data format. If empty it assumes geojson.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function create($id, $type = null, $format = null)
|
||||||
|
{
|
||||||
|
return self::createBuilder($id, $type, $format)->getUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the request builder.
|
||||||
|
*
|
||||||
|
* @param int $id Object id.
|
||||||
|
* @param string|null $type Object type. If empty it assumes a layer.
|
||||||
|
* @param string|null $format Data format. If empty it assumes geojson.
|
||||||
|
*
|
||||||
|
* @return UrlBuilder
|
||||||
|
*/
|
||||||
|
public static function createBuilder($id, $type = null, $format = null)
|
||||||
|
{
|
||||||
|
$path = \Config::get('websitePath') . '/' . static::BASE;
|
||||||
|
$builder = new UrlBuilder();
|
||||||
|
$builder
|
||||||
|
->setPath($path)
|
||||||
|
->setQueryParameter('type', $type ?: 'layer')
|
||||||
|
->setQueryParameter('format', $format ?: 'geojson')
|
||||||
|
->setQueryParameter('id', $id);
|
||||||
|
|
||||||
|
return $builder;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user