forked from Snck3rs/contao-leaflet-maps
Rework vector dca callbacks to a service listener.
This commit is contained in:
@@ -10,9 +10,10 @@
|
||||
* @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\Leaflet\Model\StyleModel;
|
||||
|
||||
@@ -21,7 +22,7 @@ use Netzmacht\Contao\Leaflet\Model\StyleModel;
|
||||
*
|
||||
* @package Netzmacht\Contao\Leaflet\Dca
|
||||
*/
|
||||
class VectorCallbacks extends Callbacks
|
||||
class VectorDcaListener extends AbstractListener
|
||||
{
|
||||
/**
|
||||
* Name of the data container.
|
||||
@@ -30,13 +31,6 @@ class VectorCallbacks extends Callbacks
|
||||
*/
|
||||
protected static $name = 'tl_leaflet_vector';
|
||||
|
||||
/**
|
||||
* Helper service name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $serviceName = 'leaflet.dca.vector-callbacks';
|
||||
|
||||
/**
|
||||
* Generate the row label.
|
||||
*
|
||||
@@ -64,4 +58,22 @@ class VectorCallbacks extends Callbacks
|
||||
|
||||
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
|
||||
arguments:
|
||||
- '@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,
|
||||
'panelLayout' => 'sort,filter;search,limit',
|
||||
'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
|
||||
(
|
||||
@@ -264,7 +264,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['popup'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'select',
|
||||
'options_callback' => array('Netzmacht\Contao\Leaflet\Dca\MarkerCallbacks', 'getPopups'),
|
||||
'options_callback' => array('Netzmacht\Contao\Leaflet\Listener\Dca\MarkerDcaListener', 'getPopups'),
|
||||
'eval' => array(
|
||||
'mandatory' => false,
|
||||
'tl_class' => 'w50',
|
||||
@@ -287,7 +287,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_leaflet_vector']['style'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'select',
|
||||
'options_callback' => Netzmacht\Contao\Leaflet\Dca\VectorCallbacks::callback('getStyles'),
|
||||
'options_callback' => ['netzmacht.contao_leaflet_maps.listeners.dca.vector', 'getStyles'],
|
||||
'eval' => array(
|
||||
'mandatory' => false,
|
||||
'tl_class' => 'w50',
|
||||
|
||||
Reference in New Issue
Block a user