8000 [FrameworkBundle] Always dump the container as XML by nicolas-grekas · Pull Request #41457 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] Always dump the container as XML #41457

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ protected function getContainerBuilder(KernelInterface $kernel): ContainerBuilde
if ($this->containerBuilder) {
return $this->containerBuilder;
}
$container = $kernel->getContainer();
$containerDump = $container->hasParameter('debug.container.dump') ? $container->getParameter('debug.container.dump') : null;

if (!$kernel->isDebug() || !(new ConfigCache($kernel->getContainer()->getParameter('debug.container.dump'), true))->isFresh()) {
if (null === $containerDump || !(new ConfigCache($containerDump, $kernel->isDebug()))->isFresh()) {
$buildContainer = \Closure::bind(function () {
$this->initializeBundles();

Expand All @@ -50,7 +52,7 @@ protected function getContainerBuilder(KernelInterface $kernel): ContainerBuilde
$container->getCompilerPassConfig()->setAfterRemovingPasses([]);
$container->compile();
} else {
(new XmlFileLoader($container = new ContainerBuilder(), new FileLocator()))->load($kernel->getContainer()->getParameter('debug.container.dump'));
(new XmlFileLoader($container = new ContainerBuilder(), new FileLocator()))->load($containerDump);
$locatorPass = new ServiceLocatorTagPass();
$locatorPass->process($container);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -938,9 +938,7 @@ private function registerDebugConfiguration(array $config, ContainerBuilder $con

$debug = $container->getParameter('kernel.debug');

if ($debug) {
$container->setParameter('debug.container.dump', '%kernel.build_dir%/%kernel.container_class%.xml');
}
$container->setParameter('debug.container.dump', '%kernel.build_dir%/%kernel.container_class%.xml');

if ($debug && class_exists(Stopwatch::class)) {
$loader->load('debug.php');
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ public function build(ContainerBuilder $container)
$container->addCompilerPass(new RegisterReverseContainerPass(false), PassConfig::TYPE_AFTER_REMOVING);
$container->addCompilerPass(new RemoveUnusedSessionMarshallingHandlerPass());
$container->addCompilerPass(new SessionPass());
$container->addCompilerPass(new ContainerBuilderDebugDumpPass(), PassConfig::TYPE_BEFORE_REMOVING, -255);

if ($container->getParameter('kernel.debug')) {
$container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 2);
$container->addCompilerPass(new UnusedTagsPass(), PassConfig::TYPE_AFTER_REMOVING);
$container->addCompilerPass(new ContainerBuilderDebugDumpPass(), PassConfig::TYPE_BEFORE_REMOVING, -255);
$container->addCompilerPass(new CacheCollectorPass(), PassConfig::TYPE_BEFORE_REMOVING);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ public function testRememberMeCookieInheritFrameworkSessionCookie($config, $same
$container->registerExtension(new FrameworkExtension());
$container->setParameter('kernel.bundles_metadata', []);
$container->setParameter('kernel.project_dir', __DIR__);
$container->setParameter('kernel.build_dir', __DIR__);
$container->setParameter('kernel.cache_dir', __DIR__);
$container->setParameter('kernel.container_class', 'FooContainer');

Expand Down
0