From a9eea3a6a17730d5790290af26da4fde5c322d72 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Thu, 11 Jan 2024 08:50:58 +0100 Subject: [PATCH] fix default theme config loader priority (#214) --- UPGRADE.md | 3 +++ src/DependencyInjection/ToolboxExtension.php | 25 +++++++++++++------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index e917e8e..929f8bf 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,8 @@ # Upgrade Notes +## 5.0.4 +- Fix default theme config loader priority + ## 5.0.3 - Respect editable configuration for standalone editables in headless document diff --git a/src/DependencyInjection/ToolboxExtension.php b/src/DependencyInjection/ToolboxExtension.php index 37aedc3..e39f0ae 100644 --- a/src/DependencyInjection/ToolboxExtension.php +++ b/src/DependencyInjection/ToolboxExtension.php @@ -46,14 +46,7 @@ public function prepend(ContainerBuilder $container): void } $coreLoader->load(sprintf('core_areas/%s_service.yaml', $areaName)); - - // @see https://github.com/symfony/symfony/issues/52789 - $data = $coreLoader->getLocator()->locate(sprintf('core_areas/%s_config.yaml', $areaName)); - $parsedData = Yaml::parseFile($data); - - if (array_key_exists('toolbox', $parsedData)) { - $container->prependExtensionConfig('toolbox', $parsedData['toolbox']); - } + $this->prependConfigToContainer($coreLoader, $container, sprintf('core_areas/%s_config.yaml', $areaName)); $loaded[] = $areaName; } @@ -61,7 +54,7 @@ public function prepend(ContainerBuilder $container): void // add default theme (b4) if not set if ($hasTheme === false) { - $coreLoader->load('theme/bootstrap4_theme.yaml'); + $this->prependConfigToContainer($coreLoader, $container, 'theme/bootstrap4_theme.yaml'); } $container->setParameter('toolbox.wysiwyg_editor', $wysiwygEditor); @@ -250,4 +243,18 @@ private function parseContextConfigs(array $configs): array return $configs; } + + private function prependConfigToContainer(YamlFileLoader $loader, ContainerBuilder $container, string $configPath): void + { + // @see https://github.com/symfony/symfony/issues/52789 + + $data = $loader->getLocator()->locate($configPath); + $parsedData = Yaml::parseFile($data, Yaml::PARSE_CONSTANT); + + if (!array_key_exists('toolbox', $parsedData)) { + return; + } + + $container->prependExtensionConfig('toolbox', $parsedData['toolbox']); + } }