Bläddra i källkod

[Console] updated console and stream outputs to support new output formatter

ever.zet 14 år sedan
förälder
incheckning
8b885a991c

+ 6 - 2
src/Symfony/Component/Console/Output/ConsoleOutput.php

@@ -11,6 +11,8 @@
 
 namespace Symfony\Component\Console\Output;
 
+use Symfony\Component\Console\Formatter\OutputFormatter;
+
 /**
  * ConsoleOutput is the default class for all CLI output. It uses STDOUT.
  *
@@ -31,9 +33,11 @@ class ConsoleOutput extends StreamOutput
      *
      * @param integer $verbosity The verbosity level (self::VERBOSITY_QUIET, self::VERBOSITY_NORMAL, self::VERBOSITY_VERBOSE)
      * @param Boolean $decorated Whether to decorate messages or not (null for auto-guessing)
+     * @param OutputFormatter   $formatter  Output formatter instance
      */
-    public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null)
+    public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null,
+                                OutputFormatter $formatter = null)
     {
-        parent::__construct(fopen('php://stdout', 'w'), $verbosity, $decorated);
+        parent::__construct(fopen('php://stdout', 'w'), $verbosity, $decorated, $formatter);
     }
 }

+ 6 - 2
src/Symfony/Component/Console/Output/StreamOutput.php

@@ -11,6 +11,8 @@
 
 namespace Symfony\Component\Console\Output;
 
+use Symfony\Component\Console\Formatter\OutputFormatter;
+
 /**
  * StreamOutput writes the output to a given stream.
  *
@@ -34,10 +36,12 @@ class StreamOutput extends Output
      * @param mixed   $stream    A stream resource
      * @param integer $verbosity The verbosity level (self::VERBOSITY_QUIET, self::VERBOSITY_NORMAL, self::VERBOSITY_VERBOSE)
      * @param Boolean $decorated Whether to decorate messages or not (null for auto-guessing)
+     * @param OutputFormatter   $formatter  Output formatter instance
      *
      * @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)
     {
         if (!is_resource($stream) || 'stream' !== get_resource_type($stream)) {
             throw new \InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');
@@ -49,7 +53,7 @@ class StreamOutput extends Output
             $decorated = $this->hasColorSupport($decorated);
         }
 
-        parent::__construct($verbosity, $decorated);
+        parent::__construct($verbosity, $decorated, $formatter);
     }
 
     /**