Use PHP's ::class constant.

This commit is contained in:
David Molineus
2017-10-11 14:50:14 +02:00
parent 8c6f4c4291
commit f09929fae7
13 changed files with 36 additions and 14 deletions

View File

@@ -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',
)

View File

@@ -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',

View File

@@ -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();
}
}

View File

@@ -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}

View File

@@ -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}

View File

@@ -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}

View File

@@ -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.

View File

@@ -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;
}

View File

@@ -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.

View File

@@ -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}

View File

@@ -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.

View File

@@ -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}

View File

@@ -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.