[Console] Moved message formatting routines into separate object #312

Merged
merged 8 commits into from Mar 18, 2011

Projects

None yet

3 participants

@everzet
Contributor
everzet commented Mar 17, 2011

Splitted actual Console Output class into 3 different logical objects:

  1. OutputFormatterStyle
  2. OutputFormatter
  3. Output

First 2 is for formatter configuration and message decoration. Third is actual output writer. This change eliminates all privatisation problems and makes output logic much cleaner

I know, we don't accept BC breaks from now on. But i've tried hard to not add BC breaks with this really helpful update. It would be very cool for Symfony2, Behat, and other project's developers if you could merge this.

@stof stof and 1 other commented on an outdated diff Mar 17, 2011
src/Symfony/Component/Console/Output/ConsoleOutput.php
*/
- public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null)
+ public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null,
+ OutputFormatter $formatter = null)
@stof
stof Mar 17, 2011 Member

This should be on the same line. method arguments are not splitted on several lines in the framework.

@everzet
everzet Mar 17, 2011 Contributor

Ok. Didn't know that.

@stof stof and 1 other commented on an outdated diff Mar 17, 2011
src/Symfony/Component/Console/Output/Output.php
@@ -33,55 +36,45 @@ abstract class Output implements OutputInterface
const OUTPUT_PLAIN = 2;
protected $verbosity;
- protected $decorated;
-
- static private $styles = array(
- 'error' => array('bg' => 'red', 'fg' => 'white'),
- 'info' => array('fg' => 'green'),
- 'comment' => array('fg' => 'yellow'),
- 'question' => array('bg' => 'cyan', 'fg' => 'black'),
- );
- static private $options = array('bold' => 1, 'underscore' => 4, 'blink' => 5, 'reverse' => 7, 'conceal' => 8);
- static private $foreground = array('black' => 30, 'red' => 31, 'green' => 32, 'yellow' => 33, 'blue' => 34, 'magenta' => 35, 'cyan' => 36, 'white' => 37);
- static private $background = array('black' => 40, 'red' => 41, 'green' => 42, 'yellow' => 43, 'blue' => 44, 'magenta' => 45, 'cyan' => 46, 'white' => 47);
+ protected $formatter;
@stof
stof Mar 17, 2011 Member

Why not using a private one as there is a getter ?

@everzet
everzet Mar 17, 2011 Contributor

You're right. I've just copied it from the old Output

@stof stof commented on an outdated diff Mar 17, 2011
src/Symfony/Component/Console/Output/StreamOutput.php
*
* @throws \InvalidArgumentException When first argument is not a real stream
*/
- public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null)
+ public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null,
+ OutputFormatter $formatter = null)
@stof
stof Mar 17, 2011 Member

Same than above.

@fabpot fabpot merged commit 3e7fa82 into symfony:master Mar 18, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment