Skip to content

Commit

Permalink
fix default theme config loader priority (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
solverat authored Jan 11, 2024
1 parent 60e2052 commit a9eea3a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
3 changes: 3 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
25 changes: 16 additions & 9 deletions src/DependencyInjection/ToolboxExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,15 @@ 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;
}
}

// 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);
Expand Down Expand Up @@ -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']);
}
}

0 comments on commit a9eea3a

Please sign in to comment.