bug #19173 [Console] Decouple SymfonyStyle from TableCell (ro0NL)
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
This commit is contained in:
commit
96f32b6512
@ -17,7 +17,6 @@ use Symfony\Component\Console\Helper\Helper;
|
|||||||
use Symfony\Component\Console\Helper\ProgressBar;
|
use Symfony\Component\Console\Helper\ProgressBar;
|
||||||
use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
|
use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
|
||||||
use Symfony\Component\Console\Helper\Table;
|
use Symfony\Component\Console\Helper\Table;
|
||||||
use Symfony\Component\Console\Helper\TableCell;
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\BufferedOutput;
|
use Symfony\Component\Console\Output\BufferedOutput;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
@ -218,21 +217,13 @@ class SymfonyStyle extends OutputStyle
|
|||||||
*/
|
*/
|
||||||
public function table(array $headers, array $rows)
|
public function table(array $headers, array $rows)
|
||||||
{
|
{
|
||||||
array_walk_recursive($headers, function (&$value) {
|
$style = clone Table::getStyleDefinition('symfony-style-guide');
|
||||||
if ($value instanceof TableCell) {
|
$style->setCellHeaderFormat('<info>%s</info>');
|
||||||
$value = new TableCell(sprintf('<info>%s</>', $value), array(
|
|
||||||
'colspan' => $value->getColspan(),
|
|
||||||
'rowspan' => $value->getRowspan(),
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
$value = sprintf('<info>%s</>', $value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$table = new Table($this);
|
$table = new Table($this);
|
||||||
$table->setHeaders($headers);
|
$table->setHeaders($headers);
|
||||||
$table->setRows($rows);
|
$table->setRows($rows);
|
||||||
$table->setStyle('symfony-style-guide');
|
$table->setStyle($style);
|
||||||
|
|
||||||
$table->render();
|
$table->render();
|
||||||
$this->newLine();
|
$this->newLine();
|
||||||
|
Reference in New Issue
Block a user