[FrameworkBundle] improve usage of Table helper
Use the `Table` helper if present in favor of the deprecated `TableHelper` class.
This commit is contained in:
parent
234cebd087
commit
71d84e66e4
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Bundle\FrameworkBundle\Command;
|
||||
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
use Symfony\Component\Console\Helper\Table;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
||||
|
||||
@ -28,15 +29,24 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand
|
||||
{
|
||||
$output->writeln('Available registered bundles with their extension alias if available:');
|
||||
|
||||
if (class_exists('Symfony\Component\Console\Helper\Table')) {
|
||||
$table = new Table($output);
|
||||
} else {
|
||||
$table = $this->getHelperSet()->get('table');
|
||||
}
|
||||
|
||||
$table->setHeaders(array('Bundle name', 'Extension alias'));
|
||||
foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
|
||||
$extension = $bundle->getContainerExtension();
|
||||
$table->addRow(array($bundle->getName(), $extension ? $extension->getAlias() : ''));
|
||||
}
|
||||
|
||||
if (class_exists('Symfony\Component\Console\Helper\Table')) {
|
||||
$table->render();
|
||||
} else {
|
||||
$table->render($output);
|
||||
}
|
||||
}
|
||||
|
||||
protected function findExtension($name)
|
||||
{
|
||||
|
@ -131,8 +131,11 @@ EOF
|
||||
}
|
||||
}
|
||||
|
||||
/** @var \Symfony\Component\Console\Helper\Table $table */
|
||||
if (class_exists('Symfony\Component\Console\Helper\Table')) {
|
||||
$table = new Table($output);
|
||||
} else {
|
||||
$table = $this->getHelperSet()->get('table');
|
||||
}
|
||||
|
||||
// Display header line
|
||||
$headers = array('State(s)', 'Id', sprintf('Message Preview (%s)', $locale));
|
||||
@ -177,7 +180,11 @@ EOF
|
||||
}
|
||||
}
|
||||
|
||||
if (class_exists('Symfony\Component\Console\Helper\Table')) {
|
||||
$table->render();
|
||||
} else {
|
||||
$table->render($output);
|
||||
}
|
||||
|
||||
$output->writeln('');
|
||||
$output->writeln('<info>Legend:</info>');
|
||||
|
Reference in New Issue
Block a user