From 51fc784800b52b13e7684237fd14bd12e311f5f0 Mon Sep 17 00:00:00 2001 From: David Molineus Date: Mon, 9 Oct 2017 15:39:50 +0200 Subject: [PATCH] Fix controls selection. --- src/Listener/Dca/ControlDcaListener.php | 21 ++++++++++++++++++- src/Resources/config/listeners.yml | 1 + .../contao/dca/tl_leaflet_control.php | 18 ++++++++-------- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/Listener/Dca/ControlDcaListener.php b/src/Listener/Dca/ControlDcaListener.php index 29f199d..403d572 100644 --- a/src/Listener/Dca/ControlDcaListener.php +++ b/src/Listener/Dca/ControlDcaListener.php @@ -41,17 +41,36 @@ class ControlDcaListener extends AbstractListener */ private $connection; + /** + * Control types. + * + * @var array + */ + private $types; + /** * Construct. * * @param Manager $manager Data container manager. * @param Connection $connection Database connection. + * @param array $types Control types. */ - public function __construct(Manager $manager, Connection $connection) + public function __construct(Manager $manager, Connection $connection, array $types) { parent::__construct($manager); $this->connection = $connection; + $this->types = $types; + } + + /** + * Get control types. + * + * @return array + */ + public function getControlTypes(): array + { + return $this->types; } /** diff --git a/src/Resources/config/listeners.yml b/src/Resources/config/listeners.yml index 9cf1389..8a3a924 100644 --- a/src/Resources/config/listeners.yml +++ b/src/Resources/config/listeners.yml @@ -26,6 +26,7 @@ services: arguments: - '@netzmacht.contao_toolkit.dca.manager' - '@database_connection' + - '%netzmacht.contao_leaflet_maps.controls%' netzmacht.contao_leaflet_maps.listeners.dca.layer: class: Netzmacht\Contao\Leaflet\Listener\Dca\LayerDcaListener diff --git a/src/Resources/contao/dca/tl_leaflet_control.php b/src/Resources/contao/dca/tl_leaflet_control.php index 3e38885..2499498 100644 --- a/src/Resources/contao/dca/tl_leaflet_control.php +++ b/src/Resources/contao/dca/tl_leaflet_control.php @@ -196,12 +196,12 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array ), 'type' => array ( - 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['type'], - 'exclude' => true, - 'inputType' => 'select', - 'filter' => true, - 'sorting' => true, - 'eval' => array( + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['type'], + 'exclude' => true, + 'inputType' => 'select', + 'filter' => true, + 'sorting' => true, + 'eval' => array( 'mandatory' => true, 'tl_class' => 'w50', 'includeBlankOption' => true, @@ -209,9 +209,9 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array 'chosen' => true, 'helpwizard' => true, ), - 'options' => $GLOBALS['LEAFLET_CONTROLS'], - 'reference' => &$GLOBALS['TL_LANG']['leaflet_control'], - 'sql' => "varchar(32) NOT NULL default ''" + 'options_callback' => ['netzmacht.contao_leaflet_maps.listeners.dca.control', 'getControlTypes'], + 'reference' => &$GLOBALS['TL_LANG']['leaflet_control'], + 'sql' => "varchar(32) NOT NULL default ''", ), 'position' => array (