forked from Snck3rs/contao-leaflet-maps
Rename doBuild to build and introduce getClassName method.
This commit is contained in:
@@ -15,9 +15,9 @@ use Netzmacht\LeafletPHP\Definition;
|
||||
use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds;
|
||||
|
||||
/**
|
||||
* Class AbstractBuilder.
|
||||
* Class AbstractMapper.
|
||||
*
|
||||
* @package Netzmacht\Contao\Leaflet\Builder
|
||||
* @package Netzmacht\Contao\Leaflet\Mapper
|
||||
*/
|
||||
abstract class AbstractMapper implements Mapper
|
||||
{
|
||||
@@ -149,13 +149,13 @@ abstract class AbstractMapper implements Mapper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function handle(\Model $model, DefinitionMapper $builder, LatLngBounds $bounds = null)
|
||||
public function handle(\Model $model, DefinitionMapper $mapper, LatLngBounds $bounds = null)
|
||||
{
|
||||
$definition = $this->createInstance($model, $builder, $bounds);
|
||||
$definition = $this->createInstance($model, $mapper, $bounds);
|
||||
|
||||
$this->buildOptions($definition, $model);
|
||||
$this->buildConditionals($definition, $model);
|
||||
$this->doBuild($definition, $model, $builder, $bounds);
|
||||
$this->build($definition, $model, $mapper, $bounds);
|
||||
|
||||
return $definition;
|
||||
}
|
||||
@@ -171,13 +171,12 @@ abstract class AbstractMapper implements Mapper
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the builder.
|
||||
* Initialize the mapper.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,15 +184,15 @@ abstract class AbstractMapper implements Mapper
|
||||
*
|
||||
* @param Definition $definition The definition being built.
|
||||
* @param \Model $model The model.
|
||||
* @param DefinitionMapper $builder The definition builder.
|
||||
* @param DefinitionMapper $mapper The definition mapper.
|
||||
* @param LatLngBounds $bounds Optional bounds where elements should be in.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function doBuild(
|
||||
protected function build(
|
||||
Definition $definition,
|
||||
\Model $model,
|
||||
DefinitionMapper $builder,
|
||||
DefinitionMapper $mapper,
|
||||
LatLngBounds $bounds = null
|
||||
) {
|
||||
}
|
||||
@@ -209,7 +208,7 @@ abstract class AbstractMapper implements Mapper
|
||||
*/
|
||||
protected function createInstance(\Model $model, DefinitionMapper $mapper, LatLngBounds $bounds = null)
|
||||
{
|
||||
$reflector = new \ReflectionClass(static::$definitionClass);
|
||||
$reflector = new \ReflectionClass($this->getClassName($model, $mapper, $bounds));
|
||||
$instance = $reflector->newInstanceArgs($this->buildConstructArguments($model, $mapper, $bounds));
|
||||
|
||||
return $instance;
|
||||
@@ -331,4 +330,18 @@ abstract class AbstractMapper implements Mapper
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get definition class name.
|
||||
*
|
||||
* @param \Model $model The model.
|
||||
* @param DefinitionMapper $mapper The definition mapper.
|
||||
* @param LatLngBounds $bounds Optional bounds where elements should be in.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getClassName(\Model $model, DefinitionMapper $mapper, LatLngBounds $bounds = null)
|
||||
{
|
||||
return static::$definitionClass;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ class AttributionControlMapper extends AbstractControlMapper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doBuild(Definition $definition, \Model $model, DefinitionMapper $builder, LatLngBounds $bounds = null)
|
||||
protected function build(Definition $definition, \Model $model, DefinitionMapper $builder, LatLngBounds $bounds = null)
|
||||
{
|
||||
if (!$definition instanceof Attribution) {
|
||||
return;
|
||||
|
||||
@@ -53,7 +53,7 @@ class GroupLayerMapper extends AbstractLayerMapper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doBuild(
|
||||
protected function build(
|
||||
Definition $definition,
|
||||
\Model $model,
|
||||
DefinitionMapper $mapper,
|
||||
|
||||
@@ -57,7 +57,7 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doBuild(
|
||||
protected function build(
|
||||
Definition $definition,
|
||||
\Model $model,
|
||||
DefinitionMapper $mapper,
|
||||
|
||||
@@ -70,7 +70,7 @@ class ProviderLayerMapper extends AbstractLayerMapper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doBuild(Definition $definition, \Model $model, DefinitionMapper $builder, LatLngBounds $bounds = null)
|
||||
protected function build(Definition $definition, \Model $model, DefinitionMapper $builder, LatLngBounds $bounds = null)
|
||||
{
|
||||
if (!empty($this->providers[$model->tile_provider]['options'])) {
|
||||
$this->applyOptions(
|
||||
|
||||
@@ -58,7 +58,7 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doBuild(
|
||||
protected function build(
|
||||
Definition $definition,
|
||||
\Model $model,
|
||||
DefinitionMapper $mapper,
|
||||
|
||||
@@ -51,7 +51,7 @@ class MapMapper extends AbstractMapper
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function doBuild(Definition $map, \Model $model, DefinitionMapper $builder, LatLngBounds $bounds = null)
|
||||
protected function build(Definition $map, \Model $model, DefinitionMapper $builder, LatLngBounds $bounds = null)
|
||||
{
|
||||
if ($map instanceof Map && $model instanceof MapModel) {
|
||||
$this->buildCustomOptions($map, $model);
|
||||
|
||||
@@ -63,7 +63,7 @@ class ImageIconMapper extends AbstractIconMapper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doBuild(
|
||||
protected function build(
|
||||
Definition $definition,
|
||||
\Model $model,
|
||||
DefinitionMapper $mapper,
|
||||
|
||||
@@ -61,7 +61,7 @@ class MarkerMapper extends AbstractMapper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doBuild(
|
||||
protected function build(
|
||||
Definition $definition,
|
||||
\Model $model,
|
||||
DefinitionMapper $builder,
|
||||
|
||||
@@ -41,13 +41,13 @@ class AbstractVectorMapper extends AbstractTypeMapper
|
||||
;
|
||||
}
|
||||
|
||||
protected function doBuild(
|
||||
protected function build(
|
||||
Definition $definition,
|
||||
\Model $model,
|
||||
DefinitionMapper $builder,
|
||||
LatLngBounds $bounds = null
|
||||
) {
|
||||
parent::doBuild($definition, $model, $builder, $bounds);
|
||||
parent::build($definition, $model, $builder, $bounds);
|
||||
|
||||
if ($definition instanceof Path) {
|
||||
if ($model->addPopup) {
|
||||
|
||||
@@ -41,13 +41,13 @@ class CircleMapper extends AbstractVectorMapper
|
||||
$this->addOption('radius');
|
||||
}
|
||||
|
||||
protected function doBuild(
|
||||
protected function build(
|
||||
Definition $definition,
|
||||
\Model $model,
|
||||
DefinitionMapper $builder,
|
||||
LatLngBounds $bounds = null
|
||||
) {
|
||||
parent::doBuild($definition, $model, $builder, $bounds);
|
||||
parent::build($definition, $model, $builder, $bounds);
|
||||
|
||||
if ($definition instanceof Circle) {
|
||||
$definition->setLatLng(LatLng::fromString($model->coordinates));
|
||||
|
||||
@@ -34,13 +34,13 @@ class MultiPolygonMapper extends MultiPolylineMapper
|
||||
*/
|
||||
protected static $type = 'multiPolygon';
|
||||
|
||||
protected function doBuild(
|
||||
protected function build(
|
||||
Definition $definition,
|
||||
\Model $model,
|
||||
DefinitionMapper $builder,
|
||||
LatLngBounds $bounds = null
|
||||
) {
|
||||
parent::doBuild($definition, $model, $builder, $bounds);
|
||||
parent::build($definition, $model, $builder, $bounds);
|
||||
|
||||
if ($definition instanceof MultiPolygon) {
|
||||
$latLngs = array();
|
||||
|
||||
@@ -36,13 +36,13 @@ class MultiPolylineMapper extends AbstractVectorMapper
|
||||
protected static $type = 'multiPolyline';
|
||||
|
||||
|
||||
protected function doBuild(
|
||||
protected function build(
|
||||
Definition $definition,
|
||||
\Model $model,
|
||||
DefinitionMapper $builder,
|
||||
LatLngBounds $bounds = null
|
||||
) {
|
||||
parent::doBuild($definition, $model, $builder, $bounds);
|
||||
parent::build($definition, $model, $builder, $bounds);
|
||||
|
||||
if ($definition instanceof MultiPolyline) {
|
||||
$latLngs = array();
|
||||
|
||||
@@ -35,13 +35,13 @@ class PolylineMapper extends AbstractVectorMapper
|
||||
protected static $type = 'polyline';
|
||||
|
||||
|
||||
protected function doBuild(
|
||||
protected function build(
|
||||
Definition $definition,
|
||||
\Model $model,
|
||||
DefinitionMapper $builder,
|
||||
LatLngBounds $bounds = null
|
||||
) {
|
||||
parent::doBuild($definition, $model, $builder, $bounds);
|
||||
parent::build($definition, $model, $builder, $bounds);
|
||||
|
||||
if ($definition instanceof Polyline) {
|
||||
array_map(
|
||||
|
||||
Reference in New Issue
Block a user