Skip to content

Commit beee233

Browse files
Merge branch '6.3' into 6.4
* 6.3: [Cache] Fix RedisTrait::createConnection for cluster [Notifier] Add docs about updating Slack messages [FrameworkBundle] Show non-bundle extensions in `debug:config` & `config:dump` list view & completion widen return type for Monolog 3 compatibility [DoctrineBridge] Remove (wrong) PHPDoc on `ContainerAwareEventManager` [FrameworkBundle] Fix `debug:config` & `config:dump` in debug mode
2 parents c6c5729 + f777350 commit beee233

File tree

6 files changed

+278
-90
lines changed

6 files changed

+278
-90
lines changed

Command/AbstractConfigCommand.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,44 @@ protected function listBundles(OutputInterface|StyleInterface $output)
5252
}
5353
}
5454

55+
protected function listNonBundleExtensions(OutputInterface|StyleInterface $output): void
56+
{
57+
$title = 'Available registered non-bundle extension aliases';
58+
$headers = ['Extension alias'];
59+
$rows = [];
60+
61+
$kernel = $this->getApplication()->getKernel();
62+
63+
$bundleExtensions = [];
64+
foreach ($kernel->getBundles() as $bundle) {
65+
if ($extension = $bundle->getContainerExtension()) {
66+
$bundleExtensions[\get_class($extension)] = true;
67+
}
68+
}
69+
70+
$extensions = $this->getContainerBuilder($kernel)->getExtensions();
71+
72+
foreach ($extensions as $alias => $extension) {
73+
if (isset($bundleExtensions[\get_class($extension)])) {
74+
continue;
75+
}
76+
$rows[] = [$alias];
77+
}
78+
79+
if (!$rows) {
80+
return;
81+
}
82+
83+
if ($output instanceof StyleInterface) {
84+
$output->title($title);
85+
$output->table($headers, $rows);
86+
} else {
87+
$output->writeln($title);
88+
$table = new Table($output);
89+
$table->setHeaders($headers)->setRows($rows)->render();
90+
}
91+
}
92+
5593
protected function findExtension(string $name): ExtensionInterface
5694
{
5795
$bundles = $this->initializeBundles();

Command/BuildDebugContainerTrait.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,14 @@ protected function getContainerBuilder(KernelInterface $kernel): ContainerBuilde
5050
$container->getCompilerPassConfig()->setAfterRemovingPasses([]);
5151
$container->compile();
5252
} else {
53-
(new XmlFileLoader($container = new ContainerBuilder(), new FileLocator()))->load($kernel->getContainer()->getParameter('debug.container.dump'));
53+
$buildContainer = \Closure::bind(function () {
54+
$containerBuilder = $this->getContainerBuilder();
55+
$this->prepareContainer($containerBuilder);
56+
57+
return $containerBuilder;
58+
}, $kernel, \get_class($kernel));
59+
$container = $buildContainer();
60+
(new XmlFileLoader($container, new FileLocator()))->load($kernel->getContainer()->getParameter('debug.container.dump'));
5461
$locatorPass = new ServiceLocatorTagPass();
5562
$locatorPass->process($container);
5663

Command/ConfigDebugCommand.php

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8181

8282
if (null === $name = $input->getArgument('name')) {
8383
$this->listBundles($errorIo);
84-
85-
$kernel = $this->getApplication()->getKernel();
86-
if ($kernel instanceof ExtensionInterface
87-
&& ($kernel instanceof ConfigurationInterface || $kernel instanceof ConfigurationExtensionInterface)
88-
&& $kernel->getAlias()
89-
) {
90-
$errorIo->table(['Kernel Extension'], [[$kernel->getAlias()]]);
91-
}
84+
$this->listNonBundleExtensions($errorIo);
9285

9386
$errorIo->comment('Provide the name of a bundle as the first argument of this command to dump its configuration. (e.g. <comment>debug:config FrameworkBundle</comment>)');
9487
$errorIo->comment('For dumping a specific option, add its path as the second argument of this command. (e.g. <comment>debug:config FrameworkBundle serializer</comment> to dump the <comment>framework.serializer</comment> configuration)');
@@ -194,12 +187,12 @@ private function getConfigForExtension(ExtensionInterface $extension, ContainerB
194187

195188
// Fall back to default config if the extension has one
196189

197-
if (!$extension instanceof ConfigurationExtensionInterface) {
190+
if (!$extension instanceof ConfigurationExtensionInterface && !$extension instanceof ConfigurationInterface) {
198191
throw new \LogicException(sprintf('The extension with alias "%s" does not have configuration.', $extensionAlias));
199192
}
200193

201194
$configs = $container->getExtensionConfig($extensionAlias);
202-
$configuration = $extension->getConfiguration($configs, $container);
195+
$configuration = $extension instanceof ConfigurationInterface ? $extension : $extension->getConfiguration($configs, $container);
203196
$this->validateConfiguration($extension, $configuration);
204197

205198
return (new Processor())->processConfiguration($configuration, $configs);
@@ -208,7 +201,8 @@ private function getConfigForExtension(ExtensionInterface $extension, ContainerB
208201
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
209202
{
210203
if ($input->mustSuggestArgumentValuesFor('name')) {
211-
$suggestions->suggestValues($this->getAvailableBundles(!preg_match('/^[A-Z]/', $input->getCompletionValue())));
204+
$suggestions->suggestValues($this->getAvailableExtensions());
205+
$suggestions->suggestValues($this->getAvailableBundles());
212206

213207
return;
214208
}
@@ -227,11 +221,23 @@ public function complete(CompletionInput $input, CompletionSuggestions $suggesti
227221
}
228222
}
229223

230-
private function getAvailableBundles(bool $alias): array
224+
private function getAvailableExtensions(): array
225+
{
226+
$kernel = $this->getApplication()->getKernel();
227+
228+
$extensions = [];
229+
foreach ($this->getContainerBuilder($kernel)->getExtensions() as $alias => $extension) {
230+
$extensions[] = $alias;
231+
}
232+
233+
return $extensions;
234+
}
235+
236+
private function getAvailableBundles(): array
231237
{
232238
$availableBundles = [];
233239
foreach ($this->getApplication()->getKernel()->getBundles() as $bundle) {
234-
$availableBundles[] = $alias ? $bundle->getContainerExtension()->getAlias() : $bundle->getName();
240+
$availableBundles[] = $bundle->getName();
235241
}
236242

237243
return $availableBundles;

Command/ConfigDumpReferenceCommand.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
use Symfony\Component\Console\Input\InputOption;
2424
use Symfony\Component\Console\Output\OutputInterface;
2525
use Symfony\Component\Console\Style\SymfonyStyle;
26-
use Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface;
27-
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
2826
use Symfony\Component\Yaml\Yaml;
2927

3028
/**
@@ -83,14 +81,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8381

8482
if (null === $name = $input->getArgument('name')) {
8583
$this->listBundles($errorIo);
86-
87-
$kernel = $this->getApplication()->getKernel();
88-
if ($kernel instanceof ExtensionInterface
89-
&& ($kernel instanceof ConfigurationInterface || $kernel instanceof ConfigurationExtensionInterface)
90-
&& $kernel->getAlias()
91-
) {
92-
$errorIo->table(['Kernel Extension'], [[$kernel->getAlias()]]);
93-
}
84+
$this->listNonBundleExtensions($errorIo);
9485

9586
$errorIo->comment([
9687
'Provide the name of a bundle as the first argument of this command to dump its default configuration. (e.g. <comment>config:dump-reference FrameworkBundle</comment>)',
@@ -158,6 +149,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
158149
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
159150
{
160151
if ($input->mustSuggestArgumentValuesFor('name')) {
152+
$suggestions->suggestValues($this->getAvailableExtensions());
161153
$suggestions->suggestValues($this->getAvailableBundles());
162154
}
163155

@@ -166,13 +158,24 @@ public function complete(CompletionInput $input, CompletionSuggestions $suggesti
166158
}
167159
}
168160

161+
private function getAvailableExtensions(): array
162+
{
163+
$kernel = $this->getApplication()->getKernel();
164+
165+
$extensions = [];
166+
foreach ($this->getContainerBuilder($kernel)->getExtensions() as $alias => $extension) {
167+
$extensions[] = $alias;
168+
}
169+
170+
return $extensions;
171+
}
172+
169173
private function getAvailableBundles(): array
170174
{
171175
$bundles = [];
172176

173177
foreach ($this->getApplication()->getKernel()->getBundles() as $bundle) {
174178
$bundles[] = $bundle->getName();
175-
$bundles[] = $bundle->getContainerExtension()->getAlias();
176179
}
177180

178181
return $bundles;

0 commit comments

Comments
 (0)