mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2026-01-17 12:55:16 +01:00
Rework frontend integration callback class to a listener service.
This commit is contained in:
@@ -10,9 +10,10 @@
|
|||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Netzmacht\Contao\Leaflet\Dca;
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Netzmacht\Contao\Leaflet\Listener\Dca;
|
||||||
|
|
||||||
use Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory;
|
|
||||||
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
|
use Netzmacht\Contao\Toolkit\Dca\Options\OptionsBuilder;
|
||||||
use Netzmacht\Contao\Leaflet\Model\MapModel;
|
use Netzmacht\Contao\Leaflet\Model\MapModel;
|
||||||
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
use Symfony\Component\Translation\TranslatorInterface as Translator;
|
||||||
@@ -22,7 +23,7 @@ use Symfony\Component\Translation\TranslatorInterface as Translator;
|
|||||||
*
|
*
|
||||||
* @package Netzmacht\Contao\Leaflet\Dca
|
* @package Netzmacht\Contao\Leaflet\Dca
|
||||||
*/
|
*/
|
||||||
class FrontendIntegration
|
final class FrontendIntegrationListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Translator.
|
* Translator.
|
||||||
@@ -41,24 +42,12 @@ class FrontendIntegration
|
|||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate the callback definition.
|
|
||||||
*
|
|
||||||
* @param string $methodName Callback method name.
|
|
||||||
*
|
|
||||||
* @return callable
|
|
||||||
*/
|
|
||||||
public static function callback($methodName)
|
|
||||||
{
|
|
||||||
return CallbackFactory::service('leaflet.dca.frontend-integration', $methodName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all leaflet maps.
|
* Get all leaflet maps.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getMaps()
|
public function getMaps(): array
|
||||||
{
|
{
|
||||||
$collection = MapModel::findAll();
|
$collection = MapModel::findAll();
|
||||||
|
|
||||||
@@ -72,7 +61,7 @@ class FrontendIntegration
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getEditMapLink($dataContainer)
|
public function getEditMapLink($dataContainer): string
|
||||||
{
|
{
|
||||||
if ($dataContainer->value < 1) {
|
if ($dataContainer->value < 1) {
|
||||||
return '';
|
return '';
|
||||||
@@ -10,6 +10,11 @@ services:
|
|||||||
arguments:
|
arguments:
|
||||||
- '@translator'
|
- '@translator'
|
||||||
|
|
||||||
|
netzmacht.contao_leaflet_maps.listeners.dca.frontend_integration:
|
||||||
|
class: Netzmacht\Contao\Leaflet\Listener\Dca\FrontendIntegrationListener
|
||||||
|
arguments:
|
||||||
|
- '@translator'
|
||||||
|
|
||||||
netzmacht.contao_leaflet_maps.listeners.dca.map:
|
netzmacht.contao_leaflet_maps.listeners.dca.map:
|
||||||
class: Netzmacht\Contao\Leaflet\Listener\Dca\MapDcaListener
|
class: Netzmacht\Contao\Leaflet\Listener\Dca\MapDcaListener
|
||||||
arguments:
|
arguments:
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ $GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_map'] = array(
|
|||||||
'label' => &$GLOBALS['TL_LANG']['tl_content']['leaflet_map'],
|
'label' => &$GLOBALS['TL_LANG']['tl_content']['leaflet_map'],
|
||||||
'inputType' => 'select',
|
'inputType' => 'select',
|
||||||
'exclude' => true,
|
'exclude' => true,
|
||||||
'options_callback' => \Netzmacht\Contao\Leaflet\Dca\FrontendIntegration::callback('getMaps'),
|
'options_callback' => ['netzmacht.contao_leaflet_maps.listeners.dca.frontend_integration', 'getMaps'],
|
||||||
'wizard' => array(
|
'wizard' => array(
|
||||||
\Netzmacht\Contao\Leaflet\Dca\FrontendIntegration::callback('getEditMapLink'),
|
['netzmacht.contao_leaflet_maps.listeners.dca.frontend_integration', 'getEditMapLink'],
|
||||||
),
|
),
|
||||||
'eval' => array(
|
'eval' => array(
|
||||||
'tl_class' => 'w50 wizard',
|
'tl_class' => 'w50 wizard',
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ $GLOBALS['TL_DCA']['tl_module']['fields']['leaflet_map'] = array(
|
|||||||
'label' => &$GLOBALS['TL_LANG']['tl_module']['leaflet_map'],
|
'label' => &$GLOBALS['TL_LANG']['tl_module']['leaflet_map'],
|
||||||
'inputType' => 'select',
|
'inputType' => 'select',
|
||||||
'exclude' => true,
|
'exclude' => true,
|
||||||
'options_callback' => \Netzmacht\Contao\Leaflet\Dca\FrontendIntegration::callback('getMaps'),
|
'options_callback' => ['netzmacht.contao_leaflet_maps.listeners.dca.frontend_integration', 'getMaps'],
|
||||||
'wizard' => array(
|
'wizard' => array(
|
||||||
\Netzmacht\Contao\Leaflet\Dca\FrontendIntegration::callback('getEditMapLink'),
|
['netzmacht.contao_leaflet_maps.listeners.dca.frontend_integration', 'getEditMapLink'],
|
||||||
),
|
),
|
||||||
'eval' => array(
|
'eval' => array(
|
||||||
'tl_class' => 'w50 wizard',
|
'tl_class' => 'w50 wizard',
|
||||||
|
|||||||
Reference in New Issue
Block a user