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

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[FrameworkBundle] improve usage of Table helper
Use the `Table` helper if present in favor of the deprecated
`TableHelper` class.
  • Loading branch information
xabbuh committed Apr 13, 2015
commit 71d84e66e425fac7f3d33fa27fe355be0e971c6a
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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

$table = $this->getHelperSet()->get('table');
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() : ''));
}

$table->render($output);
if (class_exists('Symfony\Component\Console\Helper\Table')) {
$table->render();
} else {
$table->render($output);
}
}

protected function findExtension($name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}

/** @var \Symfony\Component\Console\Helper\Table $table */
$table = new Table($output);
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));
Expand Down Expand Up @@ -177,7 +180,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}

$table->render();
if (class_exists('Symfony\Component\Console\Helper\Table')) {
$table->render();
} else {
$table->render($output);
}

$output->writeln('');
$output->writeln('<info>Legend:</info>');
Expand Down