Skip to content

Commit 71d84e6

Browse files
committed
[FrameworkBundle] improve usage of Table helper
Use the `Table` helper if present in favor of the deprecated `TableHelper` class.
1 parent 234cebd commit 71d84e6

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Command;
1313

1414
use Symfony\Component\Config\Definition\ConfigurationInterface;
15+
use Symfony\Component\Console\Helper\Table;
1516
use Symfony\Component\Console\Output\OutputInterface;
1617
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
1718

@@ -28,14 +29,23 @@ protected function listBundles(OutputInterface $output)
2829
{
2930
$output->writeln('Available registered bundles with their extension alias if available:');
3031

31-
$table = $this->getHelperSet()->get('table');
32+
if (class_exists('Symfony\Component\Console\Helper\Table')) {
33+
$table = new Table($output);
34+
} else {
35+
$table = $this->getHelperSet()->get('table');
36+
}
37+
3238
$table->setHeaders(array('Bundle name', 'Extension alias'));
3339
foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
3440
$extension = $bundle->getContainerExtension();
3541
$table->addRow(array($bundle->getName(), $extension ? $extension->getAlias() : ''));
3642
}
3743

38-
$table->render($output);
44+
if (class_exists('Symfony\Component\Console\Helper\Table')) {
45+
$table->render();
46+
} else {
47+
$table->render($output);
48+
}
3949
}
4050

4151
protected function findExtension($name)

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
131131
}
132132
}
133133

134-
/** @var \Symfony\Component\Console\Helper\Table $table */
135-
$table = new Table($output);
134+
if (class_exists('Symfony\Component\Console\Helper\Table')) {
135+
$table = new Table($output);
136+
} else {
137+
$table = $this->getHelperSet()->get('table');
138+
}
136139

137140
// Display header line
138141
$headers = array('State(s)', 'Id', sprintf('Message Preview (%s)', $locale));
@@ -177,7 +180,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
177180
}
178181
}
179182

180-
$table->render();
183+
if (class_exists('Symfony\Component\Console\Helper\Table')) {
184+
$table->render();
185+
} else {
186+
$table->render($output);
187+
}
181188

182189
$output->writeln('');
183190
$output->writeln('<info>Legend:</info>');

0 commit comments

Comments
 (0)