mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-11-28 19:13:55 +01:00
Rework vector dca callbacks to a service listener.
This commit is contained in:
@@ -10,9 +10,10 @@
|
|||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Dca;
|
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
|
||||||
|
|
||||||
use Netzmacht\Contao\Toolkit\Dca\Callback\Callbacks;
|
use Netzmacht\Contao\Leaflet\Model\IconModel;
|
||||||
|
use Netzmacht\Contao\Toolkit\Dca\Listener\AbstractListener;
|
||||||
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
|
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
|
||||||
use Netzmacht\Contao\Leaflet\Model\StyleModel;
|
use Netzmacht\Contao\Leaflet\Model\StyleModel;
|
||||||
|
|
||||||
@@ -21,7 +22,7 @@ use Netzmacht\Contao\Leaflet\Model\StyleModel;
|
|||||||
*
|
*
|
||||||
* @package Netzmacht\Contao\Leaflet\Dca
|
* @package Netzmacht\Contao\Leaflet\Dca
|
||||||
*/
|
*/
|
||||||
class VectorCallbacks extends Callbacks
|
class VectorDcaListener extends AbstractListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Name of the data container.
|
* Name of the data container.
|
||||||
@@ -30,13 +31,6 @@ class VectorCallbacks extends Callbacks
|
|||||||
*/
|
*/
|
||||||
protected static $name = 'tl_leaflet_vector';
|
protected static $name = 'tl_leaflet_vector';
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper service name.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected static $serviceName = 'leaflet.dca.vector-callbacks';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the row label.
|
* Generate the row label.
|
||||||
*
|
*
|
||||||
@@ -64,4 +58,22 @@ class VectorCallbacks extends Callbacks
|
|||||||
|
|
||||||
return OptionsBuilder::fromCollection($collection, 'title')->getOptions();
|
return OptionsBuilder::fromCollection($collection, 'title')->getOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all icons.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getIcons()
|
||||||
|
{
|
||||||
|
$collection = IconModel::findAll(array('order' => 'title'));
|
||||||
|
$builder = OptionsBuilder::fromCollection(
|
||||||
|
$collection,
|
||||||
|
function ($model) {
|
||||||
|
return sprintf('%s [%s]', $model['title'], $model['type']);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return $builder->getOptions();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -26,3 +26,8 @@ services:
|
|||||||
class: Netzmacht\Contao\Leaflet\Listener\Dca\MarkerDcaListener
|
class: Netzmacht\Contao\Leaflet\Listener\Dca\MarkerDcaListener
|
||||||
arguments:
|
arguments:
|
||||||
- '@database_connection'
|
- '@database_connection'
|
||||||
|
|
||||||
|
netzmacht.contao_leaflet_maps.listeners.dca.vector:
|
||||||
|
class: Netzmacht\Contao\Leaflet\Listener\Dca\VectorDcaListener
|
||||||
|
arguments:
|
||||||
|
- '@netzmacht.contao_toolkit.dca.manager'
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array
|
|||||||
'flag' => 1,
|
'flag' => 1,
|
||||||
'panelLayout' => 'sort,filter;search,limit',
|
'panelLayout' => 'sort,filter;search,limit',
|
||||||
'headerFields' => array('title', 'type'),
|
'headerFields' => array('title', 'type'),
|
||||||
'child_record_callback' => Netzmacht\Contao\Leaflet\Dca\VectorCallbacks::callback('generateRow'),
|
'child_record_callback' => ['netzmacht.contao_leaflet_maps.listeners.dca.vector', 'generateRow'],
|
||||||
),
|
),
|
||||||
'label' => array
|
'label' => array
|
||||||
(
|
(
|
||||||
@@ -264,7 +264,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array
|
|||||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['popup'],
|
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['popup'],
|
||||||
'exclude' => true,
|
'exclude' => true,
|
||||||
'inputType' => 'select',
|
'inputType' => 'select',
|
||||||
'options_callback' => array('Netzmacht\Contao\Leaflet\Dca\MarkerCallbacks', 'getPopups'),
|
'options_callback' => array('Netzmacht\Contao\Leaflet\Listener\Dca\MarkerDcaListener', 'getPopups'),
|
||||||
'eval' => array(
|
'eval' => array(
|
||||||
'mandatory' => false,
|
'mandatory' => false,
|
||||||
'tl_class' => 'w50',
|
'tl_class' => 'w50',
|
||||||
@@ -287,7 +287,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array
|
|||||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['style'],
|
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['style'],
|
||||||
'exclude' => true,
|
'exclude' => true,
|
||||||
'inputType' => 'select',
|
'inputType' => 'select',
|
||||||
'options_callback' => Netzmacht\Contao\Leaflet\Dca\VectorCallbacks::callback('getStyles'),
|
'options_callback' => ['netzmacht.contao_leaflet_maps.listeners.dca.vector', 'getStyles'],
|
||||||
'eval' => array(
|
'eval' => array(
|
||||||
'mandatory' => false,
|
'mandatory' => false,
|
||||||
'tl_class' => 'w50',
|
'tl_class' => 'w50',
|
||||||
|
|||||||
Reference in New Issue
Block a user