Updated the styles of the config parameters

This commit is contained in:
Javier Eguiluz 2015-09-28 20:06:02 +02:00 committed by Fabien Potencier
parent bee1faaa95
commit fdaa513cbb
3 changed files with 8 additions and 7 deletions

View File

@ -13,7 +13,6 @@ namespace Symfony\Bundle\FrameworkBundle\Command;
use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\StyleInterface; use Symfony\Component\Console\Style\StyleInterface;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
@ -26,7 +25,7 @@ use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
*/ */
abstract class AbstractConfigCommand extends ContainerDebugCommand abstract class AbstractConfigCommand extends ContainerDebugCommand
{ {
protected function listBundles(OutputInterface $output) protected function listBundles($output)
{ {
$headers = array('Bundle name', 'Extension alias'); $headers = array('Bundle name', 'Extension alias');
$rows = array(); $rows = array();
@ -35,12 +34,10 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand
$rows[] = array($bundle->getName(), $extension ? $extension->getAlias() : ''); $rows[] = array($bundle->getName(), $extension ? $extension->getAlias() : '');
} }
$message = 'Available registered bundles with their extension alias if available:';
if ($output instanceof StyleInterface) { if ($output instanceof StyleInterface) {
$output->writeln(' '.$message);
$output->table($headers, $rows); $output->table($headers, $rows);
} else { } else {
$output->writeln($message); $output->writeln('Available registered bundles with their extension alias if available:');
$table = new Table($output); $table = new Table($output);
$table->setHeaders($headers)->setRows($rows)->render($output); $table->setHeaders($headers)->setRows($rows)->render($output);
} }

View File

@ -66,6 +66,8 @@ EOF
$name = $input->getArgument('name'); $name = $input->getArgument('name');
if (empty($name)) { if (empty($name)) {
$output->comment('Provide the name of a bundle as the first argument of this command to dump its configuration.');
$output->newLine();
$this->listBundles($output); $this->listBundles($output);
return; return;
@ -85,9 +87,9 @@ EOF
$config = $processor->processConfiguration($configuration, $configs); $config = $processor->processConfiguration($configuration, $configs);
if ($name === $extension->getAlias()) { if ($name === $extension->getAlias()) {
$output->writeln(sprintf('# Current configuration for extension with alias: "%s"', $name)); $output->title(sprintf('Current configuration for extension with alias "%s"', $name));
} else { } else {
$output->writeln(sprintf('# Current configuration for "%s"', $name)); $output->title(sprintf('Current configuration for "%s"', $name));
} }
$output->writeln(Yaml::dump(array($extension->getAlias() => $config), 3)); $output->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));

View File

@ -71,6 +71,8 @@ EOF
$name = $input->getArgument('name'); $name = $input->getArgument('name');
if (empty($name)) { if (empty($name)) {
$output->comment('Provide the name of a bundle as the first argument of this command to dump its default configuration.');
$output->newLine();
$this->listBundles($output); $this->listBundles($output);
return; return;