From f09929fae7406f4bd2a908c6958e9fd9b335d3e4 Mon Sep 17 00:00:00 2001 From: David Molineus Date: Wed, 11 Oct 2017 14:50:14 +0200 Subject: [PATCH] Use PHP's ::class constant. --- src/Bundle/Resources/contao/config/config.php | 2 +- .../Resources/contao/dca/tl_leaflet_vector.php | 2 +- src/Listener/Dca/VectorDcaListener.php | 14 ++++++++++++++ src/Mapper/Control/AbstractControlMapper.php | 3 ++- src/Mapper/Layer/AbstractLayerMapper.php | 3 ++- src/Mapper/Layer/OverpassLayerMapper.php | 2 +- src/Mapper/MapMapper.php | 2 +- src/Mapper/Style/AbstractStyleMapper.php | 3 ++- src/Mapper/Style/FixedStyleMapper.php | 4 +++- src/Mapper/Type/AbstractIconMapper.php | 3 ++- src/Mapper/UI/MarkerMapper.php | 5 +++-- src/Mapper/UI/PopupMapper.php | 4 ++-- src/Mapper/Vector/AbstractVectorMapper.php | 3 ++- 13 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/Bundle/Resources/contao/config/config.php b/src/Bundle/Resources/contao/config/config.php index 5c21f12..156ba04 100644 --- a/src/Bundle/Resources/contao/config/config.php +++ b/src/Bundle/Resources/contao/config/config.php @@ -46,7 +46,7 @@ array_insert( ), 'leaflet_about' => array ( - 'callback' => 'Netzmacht\Contao\Leaflet\Backend\About', + 'callback' => Netzmacht\Contao\Leaflet\Backend\About::class, 'icon' => 'bundles/netzmachtcontaoleaflet/img/about.png', 'stylesheet' => 'bundles/netzmachtcontaoleaflet/css/about.css', ) diff --git a/src/Bundle/Resources/contao/dca/tl_leaflet_vector.php b/src/Bundle/Resources/contao/dca/tl_leaflet_vector.php index 83bc535..a33443a 100644 --- a/src/Bundle/Resources/contao/dca/tl_leaflet_vector.php +++ b/src/Bundle/Resources/contao/dca/tl_leaflet_vector.php @@ -240,7 +240,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = [ 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['popup'], 'exclude' => true, 'inputType' => 'select', - 'options_callback' => ['Netzmacht\Contao\Leaflet\Listener\Dca\MarkerDcaListener', 'getPopups'], + 'options_callback' => ['netzmacht.contao_leaflet.listeners.dca.vector', 'getPopups'], 'eval' => [ 'mandatory' => false, 'tl_class' => 'w50', diff --git a/src/Listener/Dca/VectorDcaListener.php b/src/Listener/Dca/VectorDcaListener.php index 4bc9571..0076737 100644 --- a/src/Listener/Dca/VectorDcaListener.php +++ b/src/Listener/Dca/VectorDcaListener.php @@ -13,6 +13,7 @@ namespace Netzmacht\Contao\Leaflet\Listener\Dca; use Netzmacht\Contao\Leaflet\Model\IconModel; +use Netzmacht\Contao\Leaflet\Model\PopupModel; use Netzmacht\Contao\Toolkit\Dca\Listener\AbstractListener; use Netzmacht\Contao\Toolkit\Dca\Manager; use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder; @@ -107,4 +108,17 @@ class VectorDcaListener extends AbstractListener return $builder->getOptions(); } + + /** + * Get all popups. + * + * @return array + */ + public function getPopups() + { + $collection = PopupModel::findAll(array('order' => 'title')); + $builder = OptionsBuilder::fromCollection($collection, 'title'); + + return $builder->getOptions(); + } } diff --git a/src/Mapper/Control/AbstractControlMapper.php b/src/Mapper/Control/AbstractControlMapper.php index e7664a3..0d744b4 100644 --- a/src/Mapper/Control/AbstractControlMapper.php +++ b/src/Mapper/Control/AbstractControlMapper.php @@ -13,6 +13,7 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Control; use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper; +use Netzmacht\Contao\Leaflet\Model\ControlModel; /** * Class AbstractControlMapper is the base mapper for the control model. @@ -26,7 +27,7 @@ class AbstractControlMapper extends AbstractTypeMapper * * @var string */ - protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\ControlModel'; + protected static $modelClass = ControlModel::class; /** * {@inheritdoc} diff --git a/src/Mapper/Layer/AbstractLayerMapper.php b/src/Mapper/Layer/AbstractLayerMapper.php index c8cc96e..8f79cf2 100644 --- a/src/Mapper/Layer/AbstractLayerMapper.php +++ b/src/Mapper/Layer/AbstractLayerMapper.php @@ -13,6 +13,7 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Layer; use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper; +use Netzmacht\Contao\Leaflet\Model\LayerModel; /** * Class AbstractLayerMapper is the base mapper for the layer model. @@ -26,7 +27,7 @@ class AbstractLayerMapper extends AbstractTypeMapper * * @var string */ - protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\LayerModel'; + protected static $modelClass = LayerModel::class; /** * {@inheritdoc} diff --git a/src/Mapper/Layer/OverpassLayerMapper.php b/src/Mapper/Layer/OverpassLayerMapper.php index c830662..3d4a7f2 100644 --- a/src/Mapper/Layer/OverpassLayerMapper.php +++ b/src/Mapper/Layer/OverpassLayerMapper.php @@ -39,7 +39,7 @@ class OverpassLayerMapper extends AbstractLayerMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\Contao\Leaflet\Definition\Layer\OverpassLayer'; + protected static $definitionClass = OverpassLayer::class; /** * {@inheritdoc} diff --git a/src/Mapper/MapMapper.php b/src/Mapper/MapMapper.php index 84e4dde..42f1b23 100644 --- a/src/Mapper/MapMapper.php +++ b/src/Mapper/MapMapper.php @@ -33,7 +33,7 @@ class MapMapper extends AbstractMapper * * @var string */ - protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\MapModel'; + protected static $modelClass = MapModel::class; /** * Class of the definition being created. diff --git a/src/Mapper/Style/AbstractStyleMapper.php b/src/Mapper/Style/AbstractStyleMapper.php index 6561d68..5c97117 100644 --- a/src/Mapper/Style/AbstractStyleMapper.php +++ b/src/Mapper/Style/AbstractStyleMapper.php @@ -13,6 +13,7 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Style; use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper; +use Netzmacht\Contao\Leaflet\Model\StyleModel; /** * Class AbstractStyleMapper is the base mapper for the style model. @@ -26,5 +27,5 @@ abstract class AbstractStyleMapper extends AbstractTypeMapper * * @var string */ - protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\StyleModel'; + protected static $modelClass = StyleModel::class; } diff --git a/src/Mapper/Style/FixedStyleMapper.php b/src/Mapper/Style/FixedStyleMapper.php index 6212eb9..c54d7cb 100644 --- a/src/Mapper/Style/FixedStyleMapper.php +++ b/src/Mapper/Style/FixedStyleMapper.php @@ -12,6 +12,8 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Style; +use Netzmacht\Contao\Leaflet\Definition\Style\FixedStyle; + /** * Class FixedStyleMapper maps the fixed style to the corresponding definition. * @@ -24,7 +26,7 @@ class FixedStyleMapper extends AbstractStyleMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\Contao\Leaflet\Definition\Style\FixedStyle'; + protected static $definitionClass = FixedStyle::class; /** * Style type. diff --git a/src/Mapper/Type/AbstractIconMapper.php b/src/Mapper/Type/AbstractIconMapper.php index 181a659..1bb7117 100644 --- a/src/Mapper/Type/AbstractIconMapper.php +++ b/src/Mapper/Type/AbstractIconMapper.php @@ -13,6 +13,7 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Type; use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper; +use Netzmacht\Contao\Leaflet\Model\IconModel; /** * Class AbstractIconMapper is the base mapper for the icon model. @@ -26,7 +27,7 @@ class AbstractIconMapper extends AbstractTypeMapper * * @var string */ - protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\IconModel'; + protected static $modelClass = IconModel::class; /** * {@inheritdoc} diff --git a/src/Mapper/UI/MarkerMapper.php b/src/Mapper/UI/MarkerMapper.php index a055f31..b18122f 100644 --- a/src/Mapper/UI/MarkerMapper.php +++ b/src/Mapper/UI/MarkerMapper.php @@ -17,6 +17,7 @@ use Netzmacht\Contao\Leaflet\Frontend\ValueFilter; use Netzmacht\Contao\Leaflet\Mapper\AbstractMapper; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\Contao\Leaflet\Model\IconModel; +use Netzmacht\Contao\Leaflet\Model\MarkerModel; use Netzmacht\Contao\Leaflet\Model\PopupModel; use Netzmacht\Contao\Leaflet\Request\Request; use Netzmacht\LeafletPHP\Definition; @@ -36,14 +37,14 @@ class MarkerMapper extends AbstractMapper * * @var string */ - protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\MarkerModel'; + protected static $modelClass = MarkerModel::class; /** * Class of the definition being created. * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\UI\Marker'; + protected static $definitionClass = Marker::class; /** * Frontend filter. diff --git a/src/Mapper/UI/PopupMapper.php b/src/Mapper/UI/PopupMapper.php index 6b4eb05..529afec 100644 --- a/src/Mapper/UI/PopupMapper.php +++ b/src/Mapper/UI/PopupMapper.php @@ -32,14 +32,14 @@ class PopupMapper extends AbstractMapper * * @var string */ - protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\UI\Popup'; + protected static $definitionClass = Popup::class; /** * The model class. * * @var string */ - protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\PopupModel'; + protected static $modelClass = PopupModel::class; /** * {@inheritdoc} diff --git a/src/Mapper/Vector/AbstractVectorMapper.php b/src/Mapper/Vector/AbstractVectorMapper.php index 23ee469..61a938a 100644 --- a/src/Mapper/Vector/AbstractVectorMapper.php +++ b/src/Mapper/Vector/AbstractVectorMapper.php @@ -19,6 +19,7 @@ use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\Contao\Leaflet\Model\PopupModel; use Netzmacht\Contao\Leaflet\Model\StyleModel; +use Netzmacht\Contao\Leaflet\Model\VectorModel; use Netzmacht\Contao\Leaflet\Request\Request; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\HasPopup; @@ -37,7 +38,7 @@ class AbstractVectorMapper extends AbstractTypeMapper * * @var string */ - protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\VectorModel'; + protected static $modelClass = VectorModel::class; /** * Frontend filter.