Fix controls selection.

This commit is contained in:
David Molineus
2017-10-09 15:39:50 +02:00
parent edf212b850
commit 51fc784800
3 changed files with 30 additions and 10 deletions

View File

@@ -41,17 +41,36 @@ class ControlDcaListener extends AbstractListener
*/ */
private $connection; private $connection;
/**
* Control types.
*
* @var array
*/
private $types;
/** /**
* Construct. * Construct.
* *
* @param Manager $manager Data container manager. * @param Manager $manager Data container manager.
* @param Connection $connection Database connection. * @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); parent::__construct($manager);
$this->connection = $connection; $this->connection = $connection;
$this->types = $types;
}
/**
* Get control types.
*
* @return array
*/
public function getControlTypes(): array
{
return $this->types;
} }
/** /**

View File

@@ -26,6 +26,7 @@ services:
arguments: arguments:
- '@netzmacht.contao_toolkit.dca.manager' - '@netzmacht.contao_toolkit.dca.manager'
- '@database_connection' - '@database_connection'
- '%netzmacht.contao_leaflet_maps.controls%'
netzmacht.contao_leaflet_maps.listeners.dca.layer: netzmacht.contao_leaflet_maps.listeners.dca.layer:
class: Netzmacht\Contao\Leaflet\Listener\Dca\LayerDcaListener class: Netzmacht\Contao\Leaflet\Listener\Dca\LayerDcaListener

View File

@@ -196,12 +196,12 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array
), ),
'type' => array 'type' => array
( (
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['type'], 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['type'],
'exclude' => true, 'exclude' => true,
'inputType' => 'select', 'inputType' => 'select',
'filter' => true, 'filter' => true,
'sorting' => true, 'sorting' => true,
'eval' => array( 'eval' => array(
'mandatory' => true, 'mandatory' => true,
'tl_class' => 'w50', 'tl_class' => 'w50',
'includeBlankOption' => true, 'includeBlankOption' => true,
@@ -209,9 +209,9 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array
'chosen' => true, 'chosen' => true,
'helpwizard' => true, 'helpwizard' => true,
), ),
'options' => $GLOBALS['LEAFLET_CONTROLS'], 'options_callback' => ['netzmacht.contao_leaflet_maps.listeners.dca.control', 'getControlTypes'],
'reference' => &$GLOBALS['TL_LANG']['leaflet_control'], 'reference' => &$GLOBALS['TL_LANG']['leaflet_control'],
'sql' => "varchar(32) NOT NULL default ''" 'sql' => "varchar(32) NOT NULL default ''",
), ),
'position' => array 'position' => array
( (