forked from Snck3rs/contao-leaflet-maps
Rework frontend integration callback class to a listener service.
This commit is contained in:
@@ -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 '';
|
||||
@@ -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:
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user