@@ -5,33 +5,41 @@ Formatter Helper
55================
66
77The Formatter helpers provides functions to format the output with colors.
8- You can do more advanced things with this helper thanthe things in
8+ You can do more advanced things with this helper thanyou can in
99:ref: `components-console-coloring `.
1010
11- TheFormatter Helper is included in the default helper set, which you can
11+ The`` formatter `` helper is included in the default helper set, which you can
1212get by calling
1313:method: `Symfony\\ Component\\ Console\\ Command\\ Command::getHelperSet `::
1414
1515 $formatter = $this->getHelperSet()->get('formatter');
1616
17- The methods return a string whichin most cases you want to write
18- that data to the console with
19- :method: `Symfony\\ Component\\ Console\\ Output\\ Output ::writeln ` .
17+ The methods return a string, whichyou'll usually render to the console by
18+ passing it to the
19+ :method: `OutputInterface::writeln< Symfony\\ Component\\ Console\\ Output\\ OutputInterface ::writeln> ` method .
2020
21- Printmessages in asection
21+ PrintMessages in aSection
2222---------------------------
2323
24- Symfony uses a defined style when printing to the command line.
25- It prints the section in color and with brackets around and the
26- actual message behind this section indication.
24+ Symfony offers a defined style when printing a message that belongs to some
25+ "section". It prints the section in color and with brackets around it and the
26+ actual message to the right of this. Minus the color, it looks like this:
27+
28+ ..code-block ::text
29+
30+ [SomeSection] Here is some message related to that section
2731
2832 To reproduce this style, you can use the
29- :method: `Symfony\\ Component\\ Console\\ Helper\\ FormatterHelper::formatSection `::
33+ :method: `Symfony\\ Component\\ Console\\ Helper\\ FormatterHelper::formatSection `
34+ method::
3035
31- $formattedLine = $formatter->formatSection('SomeCommand', 'Some output from within the SomeCommand');
36+ $formattedLine = $formatter->formatSection(
37+ 'SomeSection',
38+ 'Here is some message related to that section'
39+ );
3240 $output->writeln($formattedLine);
3341
34- Printmessages in ablock
42+ PrintMessages in aBlock
3543-------------------------
3644
3745Sometimes you want to be able to print a whole block of text with a background
@@ -40,13 +48,18 @@ color. Symfony uses this when printing error messages.
4048If you print your error message on more than one line manually, you will
4149notice that the background is only as long as each individual line. Use the
4250:method: `Symfony\\ Component\\ Console\\ Helper\\ FormatterHelper::formatBlock `
43- togenerate a block output::
51+ to generate a block output::
4452
4553 $errorMessages = array('Error!', 'Something went wrong');
4654 $formattedBlock = $formatter->formatBlock($errorMessages, 'error');
55+ $output->writeln($formattedBlock);
4756
4857As you can see, passing an array of messages to the
4958:method: `Symfony\\ Component\\ Console\\ Helper\\ FormatterHelper::formatBlock `
5059method creates the desired output. If you pass ``true `` as third parameter, the
51- block will be formatted with more padding (one blank line above and below the
52- messages and 2 spaces on the left and right).
60+ block will be formatted with more padding (one blank line above and below the
61+ messages and 2 spaces on the left and right).
62+
63+ The exact "style" you use in the block is up to you. In this case, you're using
64+ the pre-defined ``error `` style, but there are other styles, or you can create
65+ your own. See:ref: `components-console-coloring `.