Fix type options.

This commit is contained in:
David Molineus
2017-10-09 16:53:22 +02:00
parent a2a6d31259
commit cd88c2992b
7 changed files with 145 additions and 3 deletions

View File

@@ -0,0 +1,50 @@
<?php
/**
* Leaflet maps for Contao CMS.
*
* @package contao-leaflet-maps
* @author David Molineus <david.molineus@netzmacht.de>
* @copyright 2016-2017 netzmacht David Molineus. All rights reserved.
* @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE
* @filesource
*/
declare(strict_types=1);
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
/**
* Class IconDcaListener.
*
* @package Netzmacht\Contao\Leaflet\Listener\Dca
*/
class IconDcaListener
{
/**
* Icon type options.
*
* @var array
*/
private $icons;
/**
* IconDcaListener constructor.
*
* @param array $icons Icon type options.
*/
public function __construct(array $icons)
{
$this->icons = $icons;
}
/**
* Get icon options.
*
* @return array
*/
public function getIconOptions(): array
{
return $this->icons;
}
}

View File

@@ -0,0 +1,50 @@
<?php
/**
* Leaflet maps for Contao CMS.
*
* @package contao-leaflet-maps
* @author David Molineus <david.molineus@netzmacht.de>
* @copyright 2016-2017 netzmacht David Molineus. All rights reserved.
* @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE
* @filesource
*/
declare(strict_types=1);
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
/**
* Class StyleDcaListener.
*
* @package Netzmacht\Contao\Leaflet\Listener\Dca
*/
class StyleDcaListener
{
/**
* Style type options.
*
* @var array
*/
private $icons;
/**
* StyleDcaListener constructor.
*
* @param array $styles Styles options.
*/
public function __construct(array $styles)
{
$this->icons = $styles;
}
/**
* Get style options.
*
* @return array
*/
public function getStyleOptions(): array
{
return $this->icons;
}
}

View File

@@ -14,6 +14,7 @@ namespace Netzmacht\Contao\Leaflet\Listener\Dca;
use Netzmacht\Contao\Leaflet\Model\IconModel;
use Netzmacht\Contao\Toolkit\Dca\Listener\AbstractListener;
use Netzmacht\Contao\Toolkit\Dca\Manager;
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
use Netzmacht\Contao\Leaflet\Model\StyleModel;
@@ -31,6 +32,36 @@ class VectorDcaListener extends AbstractListener
*/
protected static $name = 'tl_leaflet_vector';
/**
* Vector options.
*
* @var array
*/
private $vectors;
/**
* Construct.
*
* @param Manager $dcaManager Data container manager.
* @param array $vectors Vectors.
*/
public function __construct(Manager $dcaManager, array $vectors)
{
parent::__construct($dcaManager);
$this->vectors = $vectors;
}
/**
* Get the vector options.
*
* @return array
*/
public function getVectorOptions(): array
{
return $this->vectors;
}
/**
* Generate the row label.
*

View File

@@ -48,6 +48,17 @@ services:
class: Netzmacht\Contao\Leaflet\Listener\Dca\VectorDcaListener
arguments:
- '@netzmacht.contao_toolkit.dca.manager'
- '%netzmacht.contao_leaflet_maps.vectors%'
netzmacht.contao_leaflet_maps.listeners.dca.icon:
class: Netzmacht\Contao\Leaflet\Listener\Dca\IconDcaListener
arguments:
- '%netzmacht.contao_leaflet_maps.icons%'
netzmacht.contao_leaflet_maps.listeners.dca.style:
class: Netzmacht\Contao\Leaflet\Listener\Dca\IconDcaListener
arguments:
- '%netzmacht.contao_leaflet_maps.styles%'
netzmacht.contao_leaflet_maps.listeners.geo_json_subscriber:
class: Netzmacht\Contao\Leaflet\Subscriber\GeoJsonSubscriber

View File

@@ -222,7 +222,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_icon'] = array
'submitOnChange' => true,
'chosen' => true,
),
'options' => &$GLOBALS['LEAFLET_ICONS'],
'options_callback' => ['netzmacht.contao_leaflet_maps.listeners.dca.icon', 'getIconOptions'],
'reference' => &$GLOBALS['TL_LANG']['leaflet_icon'],
'sql' => "varchar(32) NOT NULL default ''"
),

View File

@@ -188,7 +188,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_style'] = array
'submitOnChange' => true,
'chosen' => true,
),
'options' => &$GLOBALS['LEAFLET_STYLES'],
'options_callback' => ['netzmacht.contao_leaflet_maps.listeners.dca.style', 'getStyleOptions'],
'reference' => &$GLOBALS['TL_LANG']['leaflet_style'],
'sql' => "varchar(32) NOT NULL default ''"
),

View File

@@ -235,7 +235,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array
'chosen' => true,
'helpwizard' => true,
),
'options' => &$GLOBALS['LEAFLET_VECTORS'],
'options_callback' => ['netzmacht.contao_leaflet_maps.listeners.dca.vector', 'getVectorOptions'],
'reference' => &$GLOBALS['TL_LANG']['leaflet_vector'],
'sql' => "varchar(32) NOT NULL default ''"
),