Skip to content

Commit 5b71915

Browse files
committed
minor #5392 Wrap the table creation inside the class extending Command, so users … (harikt)
This PR was submitted for the 2.7 branch but it was merged into the 2.6 branch instead (closes #5392). Discussion ---------- Wrap the table creation inside the class extending Command, so users … …know where the comes. They can use it as standalone when needed. This PR is with the changes mentioned in #4812 Commits ------- 00e6d3e Wrap the table creation inside the class extending Command, so users know where the comes. They can use it as standalone when needed
2 parents 9dafd45 + 00e6d3e commit 5b71915

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

components/console/helpers/table.rst

+19-12
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,25 @@ To display a table, use :class:`Symfony\\Component\\Console\\Helper\\Table`,
2525
set the headers, set the rows and then render the table::
2626

2727
use Symfony\Component\Console\Helper\Table;
28-
29-
$table = new Table($output);
30-
$table
31-
->setHeaders(array('ISBN', 'Title', 'Author'))
32-
->setRows(array(
33-
array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'),
34-
array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'),
35-
array('960-425-059-0', 'The Lord of the Rings', 'J. R. R. Tolkien'),
36-
array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie'),
37-
))
38-
;
39-
$table->render();
28+
// ...
29+
30+
class SomeCommand extends Command
31+
{
32+
public function execute(InputInterface $input, OutputInterface $output)
33+
{
34+
$table = new Table($output);
35+
$table
36+
->setHeaders(array('ISBN', 'Title', 'Author'))
37+
->setRows(array(
38+
array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'),
39+
array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'),
40+
array('960-425-059-0', 'The Lord of the Rings', 'J. R. R. Tolkien'),
41+
array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie'),
42+
))
43+
;
44+
$table->render();
45+
}
46+
}
4047

4148
You can add a table separator anywhere in the output by passing an instance of
4249
:class:`Symfony\\Component\\Console\\Helper\\TableSeparator` as a row::

0 commit comments

Comments
 (0)