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

[FrameworkBundle] Fix config builder with extensions extended in build() #53989

Merged
merged 1 commit into from
Feb 20, 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
Original file line number Diff line number Diff line change
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 @@
{
$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();

Check failure on line 56 in src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php

View workflow job for this annotation

GitHub Actions / Psalm

InaccessibleMethod

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php:56:46: InaccessibleMethod: Cannot access protected method Symfony\Component\HttpKernel\Kernel::getContainerBuilder from context Symfony\Bundle\FrameworkBundle\CacheWarmer\ConfigBuilderCacheWarmer (see https://psalm.dev/003)

Check failure on line 56 in src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php

View workflow job for this annotation

GitHub Actions / Psalm

InaccessibleMethod

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php:56:46: InaccessibleMethod: Cannot access protected method Symfony\Component\HttpKernel\Kernel::getContainerBuilder from context Symfony\Bundle\FrameworkBundle\CacheWarmer\ConfigBuilderCacheWarmer (see https://psalm.dev/003)
$kernel->prepareContainer($containerBuilder);

Check failure on line 57 in src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php

View workflow job for this annotation

GitHub Actions / Psalm

InaccessibleMethod

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php:57:26: InaccessibleMethod: Cannot access protected method Symfony\Component\HttpKernel\Kernel::prepareContainer from context Symfony\Bundle\FrameworkBundle\CacheWarmer\ConfigBuilderCacheWarmer (see https://psalm.dev/003)

Check failure on line 57 in src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php

View workflow job for this annotation

GitHub Actions / Psalm

InaccessibleMethod

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php:57:26: InaccessibleMethod: Cannot access protected method Symfony\Component\HttpKernel\Kernel::prepareContainer from context Symfony\Bundle\FrameworkBundle\CacheWarmer\ConfigBuilderCacheWarmer (see https://psalm.dev/003)

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