Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix default theme config loader priority #214

Merged
merged 1 commit into from Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions 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

Expand Down
25 changes: 16 additions & 9 deletions src/DependencyInjection/ToolboxExtension.php
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']);
}
}