From b82b0109371dace9a66381b01ffda017fc09c5a5 Mon Sep 17 00:00:00 2001 From: David Molineus Date: Fri, 6 Oct 2017 14:38:43 +0200 Subject: [PATCH] Load language file in the onload callback. --- src/Listener/Dca/LeafletDcaListener.php | 11 +++++++++++ src/Resources/contao/dca/tl_leaflet_control.php | 5 +++-- src/Resources/contao/dca/tl_leaflet_layer.php | 8 +++----- src/Resources/contao/dca/tl_leaflet_map.php | 4 +--- src/Resources/contao/dca/tl_leaflet_vector.php | 4 +--- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/Listener/Dca/LeafletDcaListener.php b/src/Listener/Dca/LeafletDcaListener.php index 911afdf..99d89c8 100644 --- a/src/Listener/Dca/LeafletDcaListener.php +++ b/src/Listener/Dca/LeafletDcaListener.php @@ -12,6 +12,7 @@ namespace Netzmacht\Contao\Leaflet\Listener\Dca; +use Contao\Controller; use Contao\DataContainer; use Netzmacht\Contao\Leaflet\Model\LayerModel; use Netzmacht\LeafletPHP\Value\LatLng; @@ -50,6 +51,16 @@ class LeafletDcaListener $this->cacheDir = $cacheDir; } + /** + * Load the language files. + * + * @return void + */ + public function loadLanguageFile(): void + { + Controller::loadLanguageFile('leaflet'); + } + /** * Create the zoom range. * diff --git a/src/Resources/contao/dca/tl_leaflet_control.php b/src/Resources/contao/dca/tl_leaflet_control.php index 08bf1dd..3e38885 100644 --- a/src/Resources/contao/dca/tl_leaflet_control.php +++ b/src/Resources/contao/dca/tl_leaflet_control.php @@ -10,8 +10,6 @@ * @filesource */ -\Controller::loadLanguageFile('leaflet'); - $GLOBALS['TL_DCA']['tl_leaflet_control'] = array ( 'config' => array( @@ -26,6 +24,9 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array 'pid' => 'index', ) ), + 'onload_callback' => array( + ['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'loadLanguageFile'], + ), 'onsubmit_callback' => [ ['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'clearCache'], ], diff --git a/src/Resources/contao/dca/tl_leaflet_layer.php b/src/Resources/contao/dca/tl_leaflet_layer.php index 2e5f3d5..17e1504 100644 --- a/src/Resources/contao/dca/tl_leaflet_layer.php +++ b/src/Resources/contao/dca/tl_leaflet_layer.php @@ -25,11 +25,9 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = [ 'alias' => 'unique', ], ], - 'onload_callback' => [ - function () { - \Controller::loadLanguageFile('leaflet'); - }, - ], + 'onload_callback' => array( + ['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'loadLanguageFile'], + ), 'onsubmit_callback' => [ ['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'clearCache'], ], diff --git a/src/Resources/contao/dca/tl_leaflet_map.php b/src/Resources/contao/dca/tl_leaflet_map.php index 173c0ed..1bbfb05 100644 --- a/src/Resources/contao/dca/tl_leaflet_map.php +++ b/src/Resources/contao/dca/tl_leaflet_map.php @@ -25,9 +25,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array ) ), 'onload_callback' => array( - function () { - \Controller::loadLanguageFile('leaflet'); - } + ['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'loadLanguageFile'], ), 'onsubmit_callback' => [ ['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'clearCache'], diff --git a/src/Resources/contao/dca/tl_leaflet_vector.php b/src/Resources/contao/dca/tl_leaflet_vector.php index d70f973..b5c969c 100644 --- a/src/Resources/contao/dca/tl_leaflet_vector.php +++ b/src/Resources/contao/dca/tl_leaflet_vector.php @@ -26,9 +26,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array ) ), 'onload_callback' => array( - function () { - \Controller::loadLanguageFile('leaflet'); - } + ['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'loadLanguageFile'], ), 'onsubmit_callback' => [ ['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'clearCache'],