From 5cd680562d5e9640d291844a53697a59630caa5d Mon Sep 17 00:00:00 2001 From: David Molineus Date: Thu, 8 Jan 2015 09:51:43 +0100 Subject: [PATCH] Rename doBuild to build and introduce getClassName method. --- .../Contao/Leaflet/Mapper/AbstractMapper.php | 35 +++++++++++++------ .../Control/AttributionControlMapper.php | 2 +- .../Leaflet/Mapper/Layer/GroupLayerMapper.php | 2 +- .../Mapper/Layer/MarkersLayerMapper.php | 2 +- .../Mapper/Layer/ProviderLayerMapper.php | 2 +- .../Mapper/Layer/VectorsLayerMapper.php | 2 +- .../Contao/Leaflet/Mapper/MapMapper.php | 2 +- .../Leaflet/Mapper/Type/ImageIconMapper.php | 2 +- .../Contao/Leaflet/Mapper/UI/MarkerMapper.php | 2 +- .../Mapper/Vector/AbstractVectorMapper.php | 4 +-- .../Leaflet/Mapper/Vector/CircleMapper.php | 4 +-- .../Mapper/Vector/MultiPolygonMapper.php | 4 +-- .../Mapper/Vector/MultiPolylineMapper.php | 4 +-- .../Leaflet/Mapper/Vector/PolylineMapper.php | 4 +-- 14 files changed, 42 insertions(+), 29 deletions(-) diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/AbstractMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/AbstractMapper.php index 00483c8..459908a 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/AbstractMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/AbstractMapper.php @@ -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; + } } diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Control/AttributionControlMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Control/AttributionControlMapper.php index e488a2f..23327d5 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Control/AttributionControlMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Control/AttributionControlMapper.php @@ -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; diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/GroupLayerMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/GroupLayerMapper.php index 342037b..2391438 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/GroupLayerMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/GroupLayerMapper.php @@ -53,7 +53,7 @@ class GroupLayerMapper extends AbstractLayerMapper /** * {@inheritdoc} */ - protected function doBuild( + protected function build( Definition $definition, \Model $model, DefinitionMapper $mapper, diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkersLayerMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkersLayerMapper.php index d2e0eaa..177d311 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkersLayerMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkersLayerMapper.php @@ -57,7 +57,7 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper /** * {@inheritdoc} */ - protected function doBuild( + protected function build( Definition $definition, \Model $model, DefinitionMapper $mapper, diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ProviderLayerMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ProviderLayerMapper.php index 6859880..1986124 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ProviderLayerMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ProviderLayerMapper.php @@ -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( diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/VectorsLayerMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/VectorsLayerMapper.php index 78fe18f..16ecd57 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/VectorsLayerMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/VectorsLayerMapper.php @@ -58,7 +58,7 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper /** * {@inheritdoc} */ - protected function doBuild( + protected function build( Definition $definition, \Model $model, DefinitionMapper $mapper, diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/MapMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/MapMapper.php index 9aaa57b..972ba65 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/MapMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/MapMapper.php @@ -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); diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Type/ImageIconMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Type/ImageIconMapper.php index 5ea701e..b3660c7 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Type/ImageIconMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Type/ImageIconMapper.php @@ -63,7 +63,7 @@ class ImageIconMapper extends AbstractIconMapper /** * {@inheritdoc} */ - protected function doBuild( + protected function build( Definition $definition, \Model $model, DefinitionMapper $mapper, diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/UI/MarkerMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/UI/MarkerMapper.php index 7bc8112..6ed7f13 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/UI/MarkerMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/UI/MarkerMapper.php @@ -61,7 +61,7 @@ class MarkerMapper extends AbstractMapper /** * {@inheritdoc} */ - protected function doBuild( + protected function build( Definition $definition, \Model $model, DefinitionMapper $builder, diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/AbstractVectorMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/AbstractVectorMapper.php index 5e4df68..feeebb4 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/AbstractVectorMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/AbstractVectorMapper.php @@ -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) { diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/CircleMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/CircleMapper.php index afbc03c..16ea330 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/CircleMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/CircleMapper.php @@ -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)); diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolygonMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolygonMapper.php index 142fdb5..33f3458 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolygonMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolygonMapper.php @@ -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(); diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolylineMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolylineMapper.php index 76883b8..98ac2a0 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolylineMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolylineMapper.php @@ -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(); diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/PolylineMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/PolylineMapper.php index 2b01f62..766bef8 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/PolylineMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/PolylineMapper.php @@ -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(