forked from Snck3rs/contao-leaflet-maps
Convert array syntax and other minor code style adjustments.
This commit is contained in:
@@ -156,9 +156,9 @@ abstract class AbstractMapper implements Mapper
|
||||
Request $request = null,
|
||||
$elementId = null
|
||||
) {
|
||||
return array(
|
||||
$this->getElementId($model, $elementId)
|
||||
);
|
||||
return [
|
||||
$this->getElementId($model, $elementId),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,8 +49,8 @@ class LayersControlMapper extends AbstractControlMapper
|
||||
$elementId = null
|
||||
) {
|
||||
$arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
||||
$arguments[1] = array();
|
||||
$arguments[2] = array();
|
||||
$arguments[1] = [];
|
||||
$arguments[2] = [];
|
||||
|
||||
/** @var ControlModel $model */
|
||||
$collection = $model->findActiveLayers();
|
||||
|
||||
@@ -80,8 +80,8 @@ class LoadingControlMapper extends AbstractControlMapper
|
||||
if ($definition instanceof LoadingControl && !$definition->isSeparate() && $model->zoomControl) {
|
||||
// Only assign if zoom control is activated and part of the map.
|
||||
$control = ControlModel::findOneBy(
|
||||
array('active=1', 'type=?', 'pid=?', 'id=?'),
|
||||
array('zoom', $model->pid, $model->zoomControl)
|
||||
['active=1', 'type=?', 'pid=?', 'id=?'],
|
||||
['zoom', $model->pid, $model->zoomControl]
|
||||
);
|
||||
|
||||
if ($control) {
|
||||
|
||||
@@ -34,7 +34,7 @@ class DefinitionMapper
|
||||
*
|
||||
* @var Mapper[][]
|
||||
*/
|
||||
private $mappers = array();
|
||||
private $mappers = [];
|
||||
|
||||
/**
|
||||
* The event dispatcher.
|
||||
@@ -48,7 +48,7 @@ class DefinitionMapper
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $mapped = array();
|
||||
private $mapped = [];
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
@@ -84,7 +84,7 @@ class DefinitionMapper
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->mapped = array();
|
||||
$this->mapped = [];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -62,9 +62,9 @@ class GroupLayerMapper extends AbstractLayerMapper
|
||||
}
|
||||
|
||||
$collection = LayerModel::findBy(
|
||||
array('pid=?', 'active=1'),
|
||||
array($model->id),
|
||||
array('order' => 'sorting')
|
||||
['pid=?', 'active=1'],
|
||||
[$model->id],
|
||||
['order' => 'sorting']
|
||||
);
|
||||
|
||||
if ($collection) {
|
||||
|
||||
@@ -108,9 +108,9 @@ class MarkerClusterLayerMapper extends AbstractLayerMapper
|
||||
}
|
||||
|
||||
$collection = LayerModel::findBy(
|
||||
array('pid=?', 'active=1'),
|
||||
array($model->id),
|
||||
array('order' => 'sorting')
|
||||
['pid=?', 'active=1'],
|
||||
[$model->id],
|
||||
['order' => 'sorting']
|
||||
);
|
||||
|
||||
if ($collection) {
|
||||
|
||||
@@ -71,18 +71,18 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
$layer->setOption('boundsMode', $model->boundsMode);
|
||||
}
|
||||
|
||||
return array(
|
||||
return [
|
||||
$this->getElementId($model, $elementId),
|
||||
RequestUrl::create($model->id, null, null, $request),
|
||||
array(),
|
||||
$layer
|
||||
);
|
||||
[],
|
||||
$layer,
|
||||
];
|
||||
}
|
||||
|
||||
return array(
|
||||
return [
|
||||
$this->getElementId($model, $elementId),
|
||||
RequestUrl::create($model->id, null, null, $request)
|
||||
);
|
||||
RequestUrl::create($model->id, null, null, $request),
|
||||
];
|
||||
}
|
||||
|
||||
return parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
||||
|
||||
@@ -92,10 +92,10 @@ class ProviderLayerMapper extends AbstractLayerMapper
|
||||
Request $request = null,
|
||||
$elementId = null
|
||||
) {
|
||||
return array(
|
||||
return [
|
||||
$model->alias ?: ('layer_' . $model->id),
|
||||
$model->tile_provider,
|
||||
$model->tile_provider_variant ?: null
|
||||
);
|
||||
$model->tile_provider_variant ?: null,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
$elementId = null
|
||||
) {
|
||||
if ($model->deferred) {
|
||||
$options = array();
|
||||
$options = [];
|
||||
|
||||
if ($model->pointToLayer) {
|
||||
$options['pointToLayer'] = new Expression($model->pointToLayer);
|
||||
@@ -79,18 +79,18 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
$layer = new GeoJson($this->getElementId($model, $elementId));
|
||||
$layer->setOptions($options);
|
||||
|
||||
return array(
|
||||
return [
|
||||
$this->getElementId($model, $elementId),
|
||||
RequestUrl::create($model->id, null, null, $request),
|
||||
array(),
|
||||
$layer
|
||||
);
|
||||
[],
|
||||
$layer,
|
||||
];
|
||||
}
|
||||
|
||||
return array(
|
||||
return [
|
||||
$this->getElementId($model, $elementId),
|
||||
RequestUrl::create($model->id, null, null, $request)
|
||||
);
|
||||
RequestUrl::create($model->id, null, null, $request),
|
||||
];
|
||||
}
|
||||
|
||||
return parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
||||
|
||||
@@ -50,8 +50,8 @@ class MapMapper extends AbstractMapper
|
||||
->addOptions('center', 'zoom', 'zoomControl')
|
||||
->addOptions('dragging', 'touchZoom', 'scrollWheelZoom', 'doubleClickZoom', 'boxZoom', 'tap', 'keyboard')
|
||||
->addOptions('trackResize', 'closeOnClick', 'bounceAtZoomLimits')
|
||||
->addConditionalOptions('adjustZoomExtra', array('minZoom', 'maxZoom', 'zoomSnap', 'zoomDelta'))
|
||||
->addConditionalOptions('keyboard', array('keyboardPanOffset', 'keyboardZoomOffset'));
|
||||
->addConditionalOptions('adjustZoomExtra', ['minZoom', 'maxZoom', 'zoomSnap', 'zoomDelta'])
|
||||
->addConditionalOptions('keyboard', ['keyboardPanOffset', 'keyboardZoomOffset']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,10 +82,10 @@ class MapMapper extends AbstractMapper
|
||||
Request $request = null,
|
||||
$elementId = null
|
||||
) {
|
||||
return array(
|
||||
return [
|
||||
$this->getElementId($model, $elementId),
|
||||
$this->getElementId($model, $elementId)
|
||||
);
|
||||
$this->getElementId($model, $elementId),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +121,7 @@ class MapMapper extends AbstractMapper
|
||||
*/
|
||||
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, ['order' => 'sorting']);
|
||||
|
||||
if (!$collection) {
|
||||
return;
|
||||
@@ -207,13 +207,13 @@ class MapMapper extends AbstractMapper
|
||||
private function buildLocate(Map $map, MapModel $model)
|
||||
{
|
||||
if ($model->locate) {
|
||||
$options = array();
|
||||
$options = [];
|
||||
|
||||
$mapping = array(
|
||||
$mapping = [
|
||||
'setView' => 'locateSetView',
|
||||
'watch' => 'locateWatch',
|
||||
'enableHighAccuracy' => 'enableHighAccuracy',
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($mapping as $option => $property) {
|
||||
if ($model->$property) {
|
||||
@@ -221,11 +221,11 @@ class MapMapper extends AbstractMapper
|
||||
}
|
||||
}
|
||||
|
||||
$mapping = array(
|
||||
$mapping = [
|
||||
'maxZoom' => 'locateMaxZoom',
|
||||
'timeout' => 'locateTimeout',
|
||||
'maximumAge' => 'locateMaximumAge',
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($mapping as $option => $property) {
|
||||
if ($model->$property) {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
* @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Mapper;
|
||||
|
||||
use Contao\Model;
|
||||
@@ -30,14 +31,14 @@ class OptionsBuilder
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $options = array();
|
||||
private $options = [];
|
||||
|
||||
/**
|
||||
* Conditional option mapping.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $conditional = array();
|
||||
private $conditional = [];
|
||||
|
||||
/**
|
||||
* Add a option mapping.
|
||||
@@ -253,7 +254,7 @@ class OptionsBuilder
|
||||
*/
|
||||
private static function getDefaultOption($option, $definition)
|
||||
{
|
||||
$keys = array('has', 'is', 'get');
|
||||
$keys = ['has', 'is', 'get'];
|
||||
$suffix = ucfirst($option);
|
||||
|
||||
foreach ($keys as $key) {
|
||||
|
||||
@@ -48,7 +48,7 @@ class FixedStyleMapper extends AbstractStyleMapper
|
||||
->addConditionalOption('lineCap')
|
||||
->addConditionalOption('lineJoin')
|
||||
->addConditionalOption('dashArray')
|
||||
->addConditionalOptions('fill', array('fillColor', 'fillOpacity'))
|
||||
->addConditionalOptions('fill', ['fillColor', 'fillOpacity'])
|
||||
->addOption('fill');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,14 +95,14 @@ class ImageIconMapper extends AbstractIconMapper
|
||||
$definition->setIconUrl($file->path);
|
||||
|
||||
$file = new \File($file->path);
|
||||
$definition->setIconSize(array($file->width, $file->height));
|
||||
$definition->setIconSize([$file->width, $file->height]);
|
||||
|
||||
if (!$model->iconAnchor) {
|
||||
$definition->setIconAnchor(array($file->width / 2, $file->height));
|
||||
$definition->setIconAnchor([($file->width / 2), $file->height]);
|
||||
}
|
||||
|
||||
if (!$model->popupAnchor) {
|
||||
$definition->setPopupAnchor(array(0, 8 - $file->height));
|
||||
$definition->setPopupAnchor([0, (8 - $file->height)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,10 +137,10 @@ class ImageIconMapper extends AbstractIconMapper
|
||||
$definition->setShadowUrl($file->path);
|
||||
|
||||
$file = new \File($file->path);
|
||||
$definition->setShadowSize(array($file->width, $file->height));
|
||||
$definition->setShadowSize([$file->width, $file->height]);
|
||||
|
||||
if (!$model->shadowAnchor) {
|
||||
$definition->setShadowAnchor(array($file->width / 2, $file->height));
|
||||
$definition->setShadowAnchor([($file->width / 2), $file->height]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ class MarkerMapper extends AbstractMapper
|
||||
$elementId = null
|
||||
) {
|
||||
$arguments = parent::buildConstructArguments($model, $mapper, $request, $elementId);
|
||||
$arguments[] = array($model->latitude, $model->longitude, $model->altitude ?: null) ?: null;
|
||||
$arguments[] = [$model->latitude, $model->longitude, $model->altitude ?: null] ?: null;
|
||||
|
||||
return $arguments;
|
||||
}
|
||||
@@ -124,9 +124,9 @@ class MarkerMapper extends AbstractMapper
|
||||
|
||||
if ($model->customIcon) {
|
||||
$iconModel = IconModel::findBy(
|
||||
array('id=?', 'active=1'),
|
||||
array($model->icon),
|
||||
array('return' => 'Model')
|
||||
['id=?', 'active=1'],
|
||||
[$model->icon],
|
||||
['return' => 'Model']
|
||||
);
|
||||
|
||||
if ($iconModel) {
|
||||
|
||||
Reference in New Issue
Block a user