8000 bug #53989 [FrameworkBundle] Fix config builder with extensions exten… · symfony/symfony@6438969 · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6438969

Browse files
bug #53989 [FrameworkBundle] Fix config builder with extensions extended in build() (HypeMC)
This PR was merged into the 5.4 branch. Discussion ---------- [FrameworkBundle] Fix config builder with extensions extended in `build()` | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #53987 | License | MIT The problem is caused by the fact that the Security bundle configuration can be extended in any `Bundle::build()` or the `Kernel::build()` methods. Commits ------- 7053385 [FrameworkBundle] Fix config builder with extensions extended in `build()`
2 parents 1ba6fe3 + 7053385 commit 6438969

File tree

2 files changed

+359
-10
lines changed

2 files changed

+359
-10
lines changed

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBag;
2323
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
2424
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
25+
use Symfony\Component\HttpKernel\Kernel;
2526
use Symfony\Component\HttpKernel\KernelInterface;
2627

2728
/**
@@ -49,12 +50,27 @@ public function warmUp(string $cacheDir)
4950
{
5051
$generator = new ConfigBuilderGenerator($this->kernel->getBuildDir());
5152

52-
foreach ($this->kernel->getBundles() as $bundle) {
53-
$extension = $bundle->getContainerExtension();
54-
if (null === $extension) {
55-
continue;
53+
if ($this->kernel instanceof Kernel) {
54+
/** @var ContainerBuilder $container */
55+
$container = \Closure::bind(function (Kernel $kernel) {
56+
$containerBuilder = $kernel->getContainerBuilder();
57+
$kernel->prepareContainer($containerBuilder);
58+
59+
return $containerBuilder;
60+
}, null, $this->kernel)($this->kernel);
61+
62+
$extensions = $container->getExtensions();
63+
} else {
64+
$extensions = [];
65+
foreach ($this->kernel->getBundles() as $bundle) {
66+
$extension = $bundle->getContainerExtension();
67+
if (null !== $extension) {
68+
$extensions[] = $extension;
69+
}
5670
}
71+
}
5772

73+
foreach ($extensions as $extension) {
5874
try {
5975
$this->dumpExtension($extension, $generator);
6076
} catch (\Exception $e) {

0 commit comments

Comments
 (0)
0