Skip to content

Commit 4911e63

Browse files
committed
use Table instead of the deprecated TableHelper
1 parent 98c8ec1 commit 4911e63

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php

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

1414
use Symfony\Component\Console\Descriptor\DescriptorInterface;
15+
use Symfony\Component\Console\Helper\Table;
1516
use Symfony\Component\Console\Helper\TableHelper;
1617
use Symfony\Component\Console\Output\OutputInterface;
1718
use Symfony\Component\DependencyInjection\Alias;
@@ -71,6 +72,16 @@ public function describe(OutputInterface $output, $object, array $options = arra
7172
}
7273
}
7374

75+
/**
76+
* Returns the output.
77+
*
78+
* @return OutputInterface The output
79+
*/
80+
protected function getOutput()
81+
{
82+
return $this->output;
83+
}
84+
7485
/**
7586
* Writes content to output.
7687
*
@@ -85,17 +96,18 @@ protected function write($content, $decorated = false)
8596
/**
8697
* Writes content to output.
8798
*
88-
* @param TableHelper $table
89-
* @param bool $decorated
99+
* @param Table $table
100+
* @param bool $decorated
90101
*/
91-
protected function renderTable(TableHelper $table, $decorated = false)
102+
protected function renderTable(Table $table, $decorated = false)
92103
{
93104
if (!$decorated) {
94-
$table->setCellRowFormat('%s');
95-
$table->setCellHeaderFormat('%s');
105+
$table->getStyle()->setCellRowFormat('%s');
106+
$table->getStyle()->setCellRowContentFormat('%s');
107+
$table->getStyle()->setCellHeaderFormat('%s');
96108
}
97109

98-
$table->render($this->output);
110+
$table->render();
99111
}
100112

101113
/**

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor;
1313

14-
use Symfony\Component\Console\Helper\TableHelper;
14+
use Symfony\Component\Console\Helper\Table;
1515
use Symfony\Component\DependencyInjection\Alias;
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
1717
use Symfony\Component\DependencyInjection\Definition;
@@ -31,8 +31,8 @@ protected function describeRouteCollection(RouteCollection $routes, array $optio
3131
{
3232
$showControllers = isset($options['show_controllers']) && $options['show_controllers'];
3333
$headers = array('Name', 'Method', 'Scheme', 'Host', 'Path');
34-
$table = new TableHelper();
35-
$table->setLayout(TableHelper::LAYOUT_COMPACT);
34+
$table = new Table($this->getOutput());
35+
$table->setStyle('compact');
3636
$table->setHeaders($showControllers ? array_merge($headers, array('Controller')) : $headers);
3737

3838
foreach ($routes->all() as $name => $route) {
@@ -99,8 +99,8 @@ protected function describeRoute(Route $route, array $options = array())
9999
*/
100100
protected function describeContainerParameters(ParameterBag $parameters, array $options = array())
101101
{
102-
$table = new TableHelper();
103-
$table->setLayout(TableHelper::LAYOUT_COMPACT);
102+
$table = new Table($this->getOutput());
103+
$table->setStyle('compact');
104104
$table->setHeaders(array('Parameter', 'Value'));
105105

106106
foreach ($this->sortParameters($parameters) as $parameter => $value) {
@@ -200,8 +200,8 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
200200
$tagsCount = count($maxTags);
201201
$tagsNames = array_keys($maxTags);
202202

203-
$table = new TableHelper();
204-
$table->setLayout(TableHelper::LAYOUT_COMPACT);
203+
$table = new Table($this->getOutput());
204+
$table->setStyle('compact');
205205
$table->setHeaders(array_merge(array('Service ID'), $tagsNames, array('Scope', 'Class name')));
206206

207207
foreach ($this->sortServiceIds($serviceIds) as $serviceId) {

0 commit comments

Comments
 (0)