Skip to content

Commit

Permalink
bug #19173 [Console] Decouple SymfonyStyle from TableCell (ro0NL)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 2.7 branch (closes #19173).

Discussion
----------

[Console] Decouple SymfonyStyle from TableCell

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | ~
| License       | MIT
| Doc PR        | ~

Alternative approach, ie BC, for #19136 (i prefer that one though, as it also _fixes_ #19123 )

Commits
-------

51f59d6 [Console] Decouple SymfonyStyle from TableCell
  • Loading branch information
fabpot committed Jun 29, 2016
2 parents b111d37 + 51f59d6 commit 96f32b6
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/Symfony/Component/Console/Style/SymfonyStyle.php
Expand Up @@ -17,7 +17,6 @@
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;
Expand Down Expand Up @@ -218,21 +217,13 @@ public function caution($message)
*/
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();
Expand Down

0 comments on commit 96f32b6

Please sign in to comment.