forked from Snck3rs/contao-leaflet-maps
Code style.
This commit is contained in:
@@ -41,7 +41,7 @@ abstract class AbstractMapper implements Mapper
|
||||
protected static $definitionClass = null;
|
||||
|
||||
/**
|
||||
* Options builder
|
||||
* Options builder.
|
||||
*
|
||||
* @var OptionsBuilder
|
||||
*/
|
||||
|
||||
@@ -60,7 +60,7 @@ class DefinitionMapper
|
||||
/**
|
||||
* Add a mapper.
|
||||
*
|
||||
* @param Mapper $mapper The mapper.
|
||||
* @param Mapper $mapper The mapper.
|
||||
* @param int $priority The priority. The higher priorities get called first.
|
||||
*
|
||||
* @return $this
|
||||
@@ -165,6 +165,7 @@ class DefinitionMapper
|
||||
* @param mixed $model The data model.
|
||||
*
|
||||
* @return Mapper
|
||||
* @throws \RuntimeException If the mapper could not be found.
|
||||
*/
|
||||
private function getMapper($model)
|
||||
{
|
||||
@@ -178,7 +179,7 @@ class DefinitionMapper
|
||||
|
||||
throw new \RuntimeException(
|
||||
sprintf(
|
||||
'Could not build model "". No matching mappers found.',
|
||||
'Could not build model "%s". No matching mappers found.',
|
||||
$this->hash($model)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -63,7 +63,7 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
if ($model->pointToLayer || $model->affectBounds) {
|
||||
$layer = new GeoJson($this->getElementId($model, $elementId));
|
||||
|
||||
if ($model->pointToLayer ) {
|
||||
if ($model->pointToLayer) {
|
||||
$layer->setPointToLayer(new Expression($model->pointToLayer));
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,10 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
) {
|
||||
if ($definition instanceof GeoJson) {
|
||||
$collection = $this->loadVectorModels($model);
|
||||
$definition->setOption('affectBounds', (bool) $model->affectBounds);
|
||||
|
||||
if ($model->affectBounds) {
|
||||
$definition->setOption('affectBounds', true);
|
||||
}
|
||||
|
||||
if ($collection) {
|
||||
foreach ($collection as $item) {
|
||||
@@ -120,13 +123,7 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
}
|
||||
}
|
||||
|
||||
if ($model->pointToLayer) {
|
||||
$definition->setPointToLayer(new Expression($model->pointToLayer));
|
||||
}
|
||||
|
||||
if ($model->onEachFeature) {
|
||||
$definition->setOnEachFeature(new Expression($model->onEachFeature));
|
||||
}
|
||||
$this->addCallbacks($definition, $model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,4 +167,23 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
{
|
||||
return VectorModel::findActiveBy('pid', $model->id, array('order' => 'sorting'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add javascript callbacks.
|
||||
*
|
||||
* @param GeoJson $definition The definition.
|
||||
* @param \Model $model The database model.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function addCallbacks(GeoJson $definition, \Model $model)
|
||||
{
|
||||
if ($model->pointToLayer) {
|
||||
$definition->setPointToLayer(new Expression($model->pointToLayer));
|
||||
}
|
||||
|
||||
if ($model->onEachFeature) {
|
||||
$definition->setOnEachFeature(new Expression($model->onEachFeature));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user