diff --git a/src/Dca/FrontendIntegration.php b/src/Listener/Dca/FrontendIntegrationListener.php similarity index 83% rename from src/Dca/FrontendIntegration.php rename to src/Listener/Dca/FrontendIntegrationListener.php index 820f723..c5e7846 100644 --- a/src/Dca/FrontendIntegration.php +++ b/src/Listener/Dca/FrontendIntegrationListener.php @@ -10,9 +10,10 @@ * @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\Leaflet\Model\MapModel; use Symfony\Component\Translation\TranslatorInterface as Translator; @@ -22,7 +23,7 @@ use Symfony\Component\Translation\TranslatorInterface as Translator; * * @package Netzmacht\Contao\Leaflet\Dca */ -class FrontendIntegration +final class FrontendIntegrationListener { /** * Translator. @@ -41,24 +42,12 @@ class FrontendIntegration $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. * * @return array */ - public function getMaps() + public function getMaps(): array { $collection = MapModel::findAll(); @@ -72,7 +61,7 @@ class FrontendIntegration * * @return string */ - public function getEditMapLink($dataContainer) + public function getEditMapLink($dataContainer): string { if ($dataContainer->value < 1) { return ''; diff --git a/src/Resources/config/listeners.yml b/src/Resources/config/listeners.yml index b717b39..7120107 100644 --- a/src/Resources/config/listeners.yml +++ b/src/Resources/config/listeners.yml @@ -10,6 +10,11 @@ services: arguments: - '@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: class: Netzmacht\Contao\Leaflet\Listener\Dca\MapDcaListener arguments: diff --git a/src/Resources/contao/dca/tl_content.php b/src/Resources/contao/dca/tl_content.php index 643f586..29b6533 100644 --- a/src/Resources/contao/dca/tl_content.php +++ b/src/Resources/contao/dca/tl_content.php @@ -23,9 +23,9 @@ $GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_map'] = array( 'label' => &$GLOBALS['TL_LANG']['tl_content']['leaflet_map'], 'inputType' => 'select', 'exclude' => true, - 'options_callback' => \Netzmacht\Contao\Leaflet\Dca\FrontendIntegration::callback('getMaps'), + 'options_callback' => ['netzmacht.contao_leaflet_maps.listeners.dca.frontend_integration', 'getMaps'], 'wizard' => array( - \Netzmacht\Contao\Leaflet\Dca\FrontendIntegration::callback('getEditMapLink'), + ['netzmacht.contao_leaflet_maps.listeners.dca.frontend_integration', 'getEditMapLink'], ), 'eval' => array( 'tl_class' => 'w50 wizard', diff --git a/src/Resources/contao/dca/tl_module.php b/src/Resources/contao/dca/tl_module.php index 4e91f0a..ca1cf5f 100644 --- a/src/Resources/contao/dca/tl_module.php +++ b/src/Resources/contao/dca/tl_module.php @@ -23,9 +23,9 @@ $GLOBALS['TL_DCA']['tl_module']['fields']['leaflet_map'] = array( 'label' => &$GLOBALS['TL_LANG']['tl_module']['leaflet_map'], 'inputType' => 'select', 'exclude' => true, - 'options_callback' => \Netzmacht\Contao\Leaflet\Dca\FrontendIntegration::callback('getMaps'), + 'options_callback' => ['netzmacht.contao_leaflet_maps.listeners.dca.frontend_integration', 'getMaps'], 'wizard' => array( - \Netzmacht\Contao\Leaflet\Dca\FrontendIntegration::callback('getEditMapLink'), + ['netzmacht.contao_leaflet_maps.listeners.dca.frontend_integration', 'getEditMapLink'], ), 'eval' => array( 'tl_class' => 'w50 wizard',