Skip to content

Commit 0e9652a

Browse files
NyholmOskarStark
authored andcommitted
[FrameworkBundle] Add argument KernelInterface to BuildDebugContainerTrait::getContainerBuilder()
1 parent cc29772 commit 0e9652a

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@ private function initializeBundles()
141141
{
142142
// Re-build bundle manually to initialize DI extensions that can be extended by other bundles in their build() method
143143
// as this method is not called when the container is loaded from the cache.
144-
$container = $this->getContainerBuilder();
145-
$bundles = $this->getApplication()->getKernel()->getBundles();
144+
$kernel = $this->getApplication()->getKernel();
145+
$container = $this->getContainerBuilder($kernel);
146+
$bundles = $kernel->getBundles();
146147
foreach ($bundles as $bundle) {
147148
if ($extension = $bundle->getContainerExtension()) {
148149
$container->registerExtension($extension);

src/Symfony/Bundle/FrameworkBundle/Command/BuildDebugContainerTrait.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
1717
use Symfony\Component\DependencyInjection\ContainerBuilder;
1818
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
19+
use Symfony\Component\HttpKernel\KernelInterface;
1920

2021
/**
2122
* @internal
@@ -32,14 +33,12 @@ trait BuildDebugContainerTrait
3233
*
3334
* @throws \LogicException
3435
*/
35-
protected function getContainerBuilder(): ContainerBuilder
36+
protected function getContainerBuilder(KernelInterface $kernel): ContainerBuilder
3637
{
3738
if ($this->containerBuilder) {
3839
return $this->containerBuilder;
3940
}
4041

41-
$kernel = $this->getApplication()->getKernel();
42-
4342
if (!$kernel->isDebug() || !(new ConfigCache($kernel->getContainer()->getParameter('debug.container.dump'), true))->isFresh()) {
4443
$buildContainer = \Closure::bind(function () { return $this->buildContainer(); }, $kernel, \get_class($kernel));
4544
$container = $buildContainer();

src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
108108
if ($extension instanceof ConfigurationInterface) {
109109
$configuration = $extension;
110110
} else {
111-
$configuration = $extension->getConfiguration([], $this->getContainerBuilder());
111+
$configuration = $extension->getConfiguration([], $this->getContainerBuilder($this->getApplication()->getKernel()));
112112
}
113113

114114
$this->validateConfiguration($extension, $configuration);

src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
123123
$errorIo = $io->getErrorStyle();
124124

125125
$this->validateInput($input);
126-
$object = $this->getContainerBuilder();
126+
$kernel = $this->getApplication()->getKernel();
127+
$object = $this->getContainerBuilder($kernel);
127128

128129
if ($input->getOption('env-vars')) {
129130
$options = ['env-vars' => true];
@@ -160,12 +161,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
160161
$options['show_hidden'] = $input->getOption('show-hidden');
161162
$options['raw_text'] = $input->getOption('raw');
162163
$options['output'] = $io;
163-
$options['is_debug'] = $this->getApplication()->getKernel()->isDebug();
164+
$options['is_debug'] = $kernel->isDebug();
164165

165166
try {
166167
$helper->describe($io, $object, $options);
167168

168-
if (isset($options['id']) && isset($this->getApplication()->getKernel()->getContainer()->getRemovedIds()[$options['id']])) {
169+
if (isset($options['id']) && isset($kernel->getContainer()->getRemovedIds()[$options['id']])) {
169170
$errorIo->note(sprintf('The "%s" service or alias has been removed or inlined when the container was compiled.', $options['id']));
170171
}
171172
} catch (ServiceNotFoundException $e) {

src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7676
$io = new SymfonyStyle($input, $output);
7777
$errorIo = $io->getErrorStyle();
7878

79-
$builder = $this->getContainerBuilder();
79+
$builder = $this->getContainerBuilder($this->getApplication()->getKernel());
8080
$serviceIds = $builder->getServiceIds();
8181
$serviceIds = array_filter($serviceIds, [$this, 'filterToServiceTypes']);
8282

@@ -155,7 +155,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
155155
private function getFileLink(string $class): string
156156
{
157157
if (null === $this->fileLinkFormatter
158-
|| (null === $r = $this->getContainerBuilder()->getReflectionClass($class, false))) {
158+
|| (null === $r = $this->getContainerBuilder($this->getApplication()->getKernel())->getReflectionClass($class, false))) {
159159
return '';
160160
}
161161

src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8282
$name = $input->getArgument('name');
8383
$helper = new DescriptorHelper($this->fileLinkFormatter);
8484
$routes = $this->router->getRouteCollection();
85-
$container = $this->fileLinkFormatter ? \Closure::fromCallable([$this, 'getContainerBuilder']) : null;
85+
$container = null;
86+
if ($this->fileLinkFormatter) {
87+
$container = function () {
88+
return $this->getContainerBuilder($this->getApplication()->getKernel());
89+
};
90+
}
8691

8792
if ($name) {
8893
if (!($route = $routes->get($name)) && $matchingRoutes = $this->findRouteNameContaining($name, $routes)) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy