Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 974bbdb

Browse files
committed
Fixed parsing new JSON output of debug:config not possible
1 parent 5b66f26 commit 974bbdb

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ protected function configure(): void
5050
new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'),
5151
new InputOption('resolve-env', null, InputOption::VALUE_NONE, 'Display resolved environment variable values instead of placeholders'),
5252
new InputOption('format', null, InputOption::VALUE_REQUIRED, sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())), class_exists(Yaml::class) ? 'yaml' : 'json'),
53+
new InputOption('no-title', null, InputOption::VALUE_NONE, 'Does not output the title, useful when the output should be parsed using json or yaml.'),
5354
])
5455
->setHelp(<<<EOF
5556
The <info>%command.name%</info> command dumps the current configuration for an
@@ -104,9 +105,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
104105
}
105106

106107
if (null === $path = $input->getArgument('path')) {
107-
$io->title(
108-
sprintf('Current configuration for %s', $name === $extensionAlias ? sprintf('extension with alias "%s"', $extensionAlias) : sprintf('"%s"', $name))
109-
);
108+
if (!$input->getOption('no-title')) {
109+
$io->title(
110+
sprintf('Current configuration for %s', $name === $extensionAlias ? sprintf('extension with alias "%s"', $extensionAlias) : sprintf('"%s"', $name))
111+
);
112+
}
110113

111114
$io->writeln($this->convertToFormat([$extensionAlias => $config], $format));
112115

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,19 @@ public function testDumpBundleOption(bool $debug)
8484
$this->assertStringContainsString('foo', $tester->getDisplay());
8585
}
8686

87+
/**
88+
* @testWith [true]
89+
* [false]
90+
*/
91+
public function testDumpWithoutTitleIsValidJson(bool $debug)
92+
{
93+
$tester = $this->createCommandTester($debug);
94+
$ret = $tester->execute(['name' => 'TestBundle', '--format' => 'json', '--no-title' => true]);
95+
96+
$this->assertSame(0, $ret, 'Returns 0 in case of success');
97+
$this->assertJson($tester->getDisplay());
98+
}
99+
87100
/**
88101
* @testWith [true]
89102
* [false]

0 commit comments

Comments
 (0)