Skip to content

Commit

Permalink
[FrameworkBundle] Fix config builder with extensions extended in `bui…
Browse files Browse the repository at this point in the history
…ld()`
  • Loading branch information
HypeMC committed Feb 20, 2024
1 parent f30cf8a commit 224f690
Show file tree
Hide file tree
Showing 2 changed files with 359 additions and 10 deletions.
24 changes: 20 additions & 4 deletions CacheWarmer/ConfigBuilderCacheWarmer.php
Expand Up @@ -22,6 +22,7 @@
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBag;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\HttpKernel\KernelInterface;

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

foreach ($this->kernel->getBundles() as $bundle) {
$extension = $bundle->getContainerExtension();
if (null === $extension) {
continue;
if ($this->kernel instanceof Kernel) {
/** @var ContainerBuilder $container */
$container = \Closure::bind(function (Kernel $kernel) {
$containerBuilder = $kernel->getContainerBuilder();
$kernel->prepareContainer($containerBuilder);

return $containerBuilder;
}, null, $this->kernel)($this->kernel);

$extensions = $container->getExtensions();
} else {
$extensions = [];
foreach ($this->kernel->getBundles() as $bundle) {
$extension = $bundle->getContainerExtension();
if (null !== $extension) {
$extensions[] = $extension;
}
}
}

foreach ($extensions as $extension) {
try {
$this->dumpExtension($extension, $generator);
} catch (\Exception $e) {
Expand Down

0 comments on commit 224f690

Please sign in to comment.