merged branch jfsimon/issue-4495 (PR #4496)
Commits -------5f328de
[console] Fixed docblock.c80e156
[console] Added style stack getter in formatter.0ae5a45
[console] Removed hardcoded empty style from styles stack. Discussion ---------- [console] Removed hardcoded style formatter from style stack. Bug fix: yes Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes This PR make it possible to replace OutputFormatter again. Fixes issue #4495. --------------------------------------------------------------------------- by travisbot at 2012-06-06T15:29:44Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1531654) (mergedc80e156f
into1541fe26
). --------------------------------------------------------------------------- by travisbot at 2012-06-06T15:29:53Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1533586) (merged5f328dee
into1541fe26
).
This commit is contained in:
commit
29542c162b
@ -138,6 +138,14 @@ class OutputFormatter implements OutputFormatterInterface
|
||||
return preg_replace_callback(self::FORMAT_PATTERN, array($this, 'replaceStyle'), $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return OutputFormatterStyleStack
|
||||
*/
|
||||
public function getStyleStack()
|
||||
{
|
||||
return $this->styleStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces style of the output.
|
||||
*
|
||||
|
@ -17,15 +17,23 @@ namespace Symfony\Component\Console\Formatter;
|
||||
class OutputFormatterStyleStack
|
||||
{
|
||||
/**
|
||||
* @var OutputFormatterStyle[]
|
||||
* @var OutputFormatterStyleInterface[]
|
||||
*/
|
||||
private $styles;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @var OutputFormatterStyleInterface
|
||||
*/
|
||||
public function __construct()
|
||||
private $emptyStyle;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param OutputFormatterStyleInterface $emptyStyle
|
||||
*/
|
||||
public function __construct(OutputFormatterStyleInterface $emptyStyle = null)
|
||||
{
|
||||
$this->emptyStyle = $emptyStyle ?: new OutputFormatterStyle();
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
@ -59,7 +67,7 @@ class OutputFormatterStyleStack
|
||||
public function pop(OutputFormatterStyleInterface $style = null)
|
||||
{
|
||||
if (empty($this->styles)) {
|
||||
return new OutputFormatterStyle();
|
||||
return $this->emptyStyle;
|
||||
}
|
||||
|
||||
if (null === $style) {
|
||||
@ -85,9 +93,29 @@ class OutputFormatterStyleStack
|
||||
public function getCurrent()
|
||||
{
|
||||
if (empty($this->styles)) {
|
||||
return new OutputFormatterStyle();
|
||||
return $this->emptyStyle;
|
||||
}
|
||||
|
||||
return $this->styles[count($this->styles)-1];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OutputFormatterStyleInterface $emptyStyle
|
||||
*
|
||||
* @return OutputFormatterStyleStack
|
||||
*/
|
||||
public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle)
|
||||
{
|
||||
$this->emptyStyle = $emptyStyle;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return OutputFormatterStyleInterface
|
||||
*/
|
||||
public function getEmptyStyle()
|
||||
{
|
||||
return $this->emptyStyle;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user