Load language file in the onload callback.

This commit is contained in:
David Molineus
2017-10-06 14:38:43 +02:00
parent 47713e8a38
commit b82b010937
5 changed files with 19 additions and 13 deletions

View File

@@ -12,6 +12,7 @@
namespace Netzmacht\Contao\Leaflet\Listener\Dca; namespace Netzmacht\Contao\Leaflet\Listener\Dca;
use Contao\Controller;
use Contao\DataContainer; use Contao\DataContainer;
use Netzmacht\Contao\Leaflet\Model\LayerModel; use Netzmacht\Contao\Leaflet\Model\LayerModel;
use Netzmacht\LeafletPHP\Value\LatLng; use Netzmacht\LeafletPHP\Value\LatLng;
@@ -50,6 +51,16 @@ class LeafletDcaListener
$this->cacheDir = $cacheDir; $this->cacheDir = $cacheDir;
} }
/**
* Load the language files.
*
* @return void
*/
public function loadLanguageFile(): void
{
Controller::loadLanguageFile('leaflet');
}
/** /**
* Create the zoom range. * Create the zoom range.
* *

View File

@@ -10,8 +10,6 @@
* @filesource * @filesource
*/ */
\Controller::loadLanguageFile('leaflet');
$GLOBALS['TL_DCA']['tl_leaflet_control'] = array $GLOBALS['TL_DCA']['tl_leaflet_control'] = array
( (
'config' => array( 'config' => array(
@@ -26,6 +24,9 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array
'pid' => 'index', 'pid' => 'index',
) )
), ),
'onload_callback' => array(
['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'loadLanguageFile'],
),
'onsubmit_callback' => [ 'onsubmit_callback' => [
['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'clearCache'], ['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'clearCache'],
], ],

View File

@@ -25,11 +25,9 @@ $GLOBALS['TL_DCA']['tl_leaflet_layer'] = [
'alias' => 'unique', 'alias' => 'unique',
], ],
], ],
'onload_callback' => [ 'onload_callback' => array(
function () { ['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'loadLanguageFile'],
\Controller::loadLanguageFile('leaflet'); ),
},
],
'onsubmit_callback' => [ 'onsubmit_callback' => [
['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'clearCache'], ['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'clearCache'],
], ],

View File

@@ -25,9 +25,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_map'] = array
) )
), ),
'onload_callback' => array( 'onload_callback' => array(
function () { ['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'loadLanguageFile'],
\Controller::loadLanguageFile('leaflet');
}
), ),
'onsubmit_callback' => [ 'onsubmit_callback' => [
['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'clearCache'], ['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'clearCache'],

View File

@@ -26,9 +26,7 @@ $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array
) )
), ),
'onload_callback' => array( 'onload_callback' => array(
function () { ['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'loadLanguageFile'],
\Controller::loadLanguageFile('leaflet');
}
), ),
'onsubmit_callback' => [ 'onsubmit_callback' => [
['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'clearCache'], ['netzmacht.contao_leaflet_maps.listeners.dca.leaflet', 'clearCache'],