diff --git a/src/EventListener/DataContainer/PageInitializationListener.php b/src/EventListener/DataContainer/PageInitializationListener.php index 16700fa..046c63e 100644 --- a/src/EventListener/DataContainer/PageInitializationListener.php +++ b/src/EventListener/DataContainer/PageInitializationListener.php @@ -4,10 +4,10 @@ namespace Terminal42\ChangeLanguage\EventListener\DataContainer; +use Contao\CoreBundle\DataContainer\PaletteManipulator; use Contao\DataContainer; use Contao\Input; use Contao\PageModel; -use Haste\Dca\PaletteManipulator; class PageInitializationListener { @@ -97,9 +97,8 @@ private function addRootLanguageFields(): void /** * @param array|string $palettes - * @param bool $addLanguageMain */ - private function addRegularLanguageFields($palettes, $addLanguageMain = true): void + private function addRegularLanguageFields($palettes, bool $addLanguageMain = true): void { $pm = PaletteManipulator::create() ->addLegend('language_legend', 'meta_legend', PaletteManipulator::POSITION_BEFORE, true) @@ -111,6 +110,10 @@ private function addRegularLanguageFields($palettes, $addLanguageMain = true): v } foreach ((array) $palettes as $palette) { + if (!isset($GLOBALS['TL_DCA']['tl_page']['palettes'][$palette])) { + continue; + } + $pm->applyToPalette($palette, 'tl_page'); } }