Skip to content

Commit 219f455

Browse files
committed
[FrameworkBundle] Removed the use of TableHelper
1 parent aedb247 commit 219f455

39 files changed

+84
-73
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ abstract class Descriptor implements DescriptorInterface
3030
/**
3131
* @var OutputInterface
3232
*/
33-
private $output;
33+
protected $output;
3434

3535
/**
3636
* {@inheritdoc}

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

Lines changed: 12 additions & 16 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;
@@ -32,8 +32,8 @@ protected function describeRouteCollection(RouteCollection $routes, array $optio
3232
{
3333
$showControllers = isset($options['show_controllers']) && $options['show_controllers'];
3434
$headers = array('Name', 'Method', 'Scheme', 'Host', 'Path');
35-
$table = new TableHelper();
36-
$table->setLayout(TableHelper::LAYOUT_COMPACT);
35+
36+
$table = new Table($this->output);
3737
$table->setHeaders($showControllers ? array_merge($headers, array('Controller')) : $headers);
3838

3939
foreach ($routes->all() as $name => $route) {
@@ -59,7 +59,7 @@ protected function describeRouteCollection(RouteCollection $routes, array $optio
5959
}
6060

6161
$this->writeText($this->formatSection('router', 'Current routes')."\n", $options);
62-
$this->renderTable($table, !(isset($options['raw_output']) && $options['raw_output']));
62+
$table->render();
6363
}
6464

6565
/**
@@ -100,16 +100,15 @@ protected function describeRoute(Route $route, array $options = array())
100100
*/
101101
protected function describeContainerParameters(ParameterBag $parameters, array $options = array())
102102
{
103-
$table = new TableHelper();
104-
$table->setLayout(TableHelper::LAYOUT_COMPACT);
103+
$table = new Table($this->output);
105104
$table->setHeaders(array('Parameter', 'Value'));
106105

107106
foreach ($this->sortParameters($parameters) as $parameter => $value) {
108107
$table->addRow(array($parameter, $this->formatParameter($value)));
109108
}
110109

111110
$this->writeText($this->formatSection('container', 'List of parameters')."\n", $options);
112-
$this->renderTable($table, !(isset($options['raw_output']) && $options['raw_output']));
111+
$table->render();
113112
}
114113

115114
/**
@@ -201,8 +200,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
201200
$tagsCount = count($maxTags);
202201
$tagsNames = array_keys($maxTags);
203202

204-
$table = new TableHelper();
205-
$table->setLayout(TableHelper::LAYOUT_COMPACT);
203+
$table = new Table($this->output);
206204
$table->setHeaders(array_merge(array('Service ID'), $tagsNames, array('Class name')));
207205

208206
foreach ($this->sortServiceIds($serviceIds) as $serviceId) {
@@ -232,7 +230,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
232230
}
233231
}
234232

235-
$this->renderTable($table);
233+
$table->render();
236234
}
237235

238236
/**
@@ -302,31 +300,29 @@ protected function describeEventDispatcherListeners(EventDispatcherInterface $ev
302300
$this->writeText($this->formatSection('event_dispatcher', $label)."\n", $options);
303301

304302
$registeredListeners = $eventDispatcher->getListeners($event);
303+
$table = new Table($this->output);
304+
305305
if (null !== $event) {
306306
$this->writeText("\n");
307-
$table = new TableHelper();
308307
$table->setHeaders(array('Order', 'Callable'));
309308

310309
foreach ($registeredListeners as $order => $listener) {
311310
$table->addRow(array(sprintf('#%d', $order + 1), $this->formatCallable($listener)));
312311
}
313-
314-
$this->renderTable($table);
315312
} else {
316313
ksort($registeredListeners);
317314
foreach ($registeredListeners as $eventListened => $eventListeners) {
318315
$this->writeText(sprintf("\n<info>[Event]</info> %s\n", $eventListened), $options);
319316

320-
$table = new TableHelper();
321317
$table->setHeaders(array('Order', 'Callable'));
322318

323319
foreach ($eventListeners as $order => $eventListener) {
324320
$table->addRow(array(sprintf('#%d', $order + 1), $this->formatCallable($eventListener)));
325321
}
326-
327-
$this->renderTable($table);
328322
}
329323
}
324+
325+
$table->render();
330326
}
331327

332328
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ private function assertDescription($expectedDescription, $describedObject, array
137137
if ('json' === $this->getFormat()) {
138138
$this->assertEquals(json_decode($expectedDescription), json_decode($output->fetch()));
139139
} else {
140-
$this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $output->fetch())));
140+
$this->assertEquals($expectedDescription, $output->fetch());
141141
}
142142
}
143143

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
- Service: `service_1`
2-
- Public: yes
2+
- Public: yes
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
- Service: `service_2`
2-
- Public: no
2+
- Public: no

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ alias_2
3232
Services
3333
--------
3434
35-
- `service_container`: `Symfony\Component\DependencyInjection\ContainerBuilder`
35+
- `service_container`: `Symfony\Component\DependencyInjection\ContainerBuilder`
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<info>[container]</info> <comment>Public</comment> services
2-
Service ID Class name
3-
alias_1 alias for "service_1"
4-
alias_2 alias for "service_2"
5-
definition_1 Full\Qualified\Class1
6-
service_container Symfony\Component\DependencyInjection\ContainerBuilder
2+
+-------------------+--------------------------------------------------------+
3+
| Service ID | Class name |
4+
+-------------------+--------------------------------------------------------+
5+
| alias_1 | alias for "service_1" |
6+
| alias_2 | alias for "service_2" |
7+
| definition_1 | Full\Qualified\Class1 |
8+
| service_container | Symfony\Component\DependencyInjection\ContainerBuilder |
9+
+-------------------+--------------------------------------------------------+

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ alias_2
4747
Services
4848
--------
4949

50-
- `service_container`: `Symfony\Component\DependencyInjection\ContainerBuilder`
50+
- `service_container`: `Symfony\Component\DependencyInjection\ContainerBuilder`
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<info>[container]</info> <comment>Public</comment> and <comment>private</comment> services
2-
Service ID Class name
3-
alias_1 alias for "service_1"
4-
alias_2 alias for "service_2"
5-
definition_1 Full\Qualified\Class1
6-
definition_2 Full\Qualified\Class2
7-
service_container Symfony\Component\DependencyInjection\ContainerBuilder
8-
2+
+-------------------+--------------------------------------------------------+
3+
| Service ID | Class name |
4+
+-------------------+--------------------------------------------------------+
5+
| alias_1 | alias for "service_1" |
6+
| alias_2 | alias for "service_2" |
7+
| definition_1 | Full\Qualified\Class1 |
8+
| definition_2 | Full\Qualified\Class2 |
9+
| service_container | Symfony\Component\DependencyInjection\ContainerBuilder |
10+
+-------------------+--------------------------------------------------------+
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<info>[container]</info> <comment>Public</comment> and <comment>private</comment> services with tag <info>tag1</info>
2-
Service ID attr1 attr2 attr3 Class name
3-
definition_2 val1 val2 Full\Qualified\Class2
4-
" val3
2+
+--------------+-------+-------+-------+-----------------------+
3+
| Service ID | attr1 | attr2 | attr3 | Class name |
4+
+--------------+-------+-------+-------+-----------------------+
5+
| definition_2 | val1 | val2 | | Full\Qualified\Class2 |
6+
| " | | | val3 | |
7+
+--------------+-------+-------+-------+-----------------------+

0 commit comments

Comments
 (0)