[Console] Decouple SymfonyStyle from TableCell

This commit is contained in:
Roland Franssen 2016-06-24 15:39:41 +00:00 committed by Fabien Potencier
parent fad545aff9
commit 51f59d6f62
1 changed files with 3 additions and 12 deletions

View File

@ -17,7 +17,6 @@ use Symfony\Component\Console\Helper\Helper;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Helper\TableCell;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Output\OutputInterface;
@ -218,21 +217,13 @@ class SymfonyStyle extends OutputStyle
*/
public function table(array $headers, array $rows)
{
array_walk_recursive($headers, function (&$value) {
if ($value instanceof TableCell) {
$value = new TableCell(sprintf('<info>%s</>', $value), array(
'colspan' => $value->getColspan(),
'rowspan' => $value->getRowspan(),
));
} else {
$value = sprintf('<info>%s</>', $value);
}
});
$style = clone Table::getStyleDefinition('symfony-style-guide');
$style->setCellHeaderFormat('<info>%s</info>');
$table = new Table($this);
$table->setHeaders($headers);
$table->setRows($rows);
$table->setStyle('symfony-style-guide');
$table->setStyle($style);
$table->render();
$this->newLine();