Skip to content

Commit

Permalink
Ignore page type if palette does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Jun 24, 2022
1 parent 2240121 commit 51ff1a6
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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)
Expand All @@ -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');
}
}
Expand Down

0 comments on commit 51ff1a6

Please sign in to comment.