From d92f3ea29ee75b97a6c5dc730b662fda509d31b0 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 12 Jun 2016 09:55:59 +0200 Subject: [PATCH] [Console] added explanation of messages usage in a progress bar --- src/Symfony/Component/Console/Helper/ProgressBar.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Helper/ProgressBar.php b/src/Symfony/Component/Console/Helper/ProgressBar.php index 1b2eefd29e..261141ff1d 100644 --- a/src/Symfony/Component/Console/Helper/ProgressBar.php +++ b/src/Symfony/Component/Console/Helper/ProgressBar.php @@ -41,7 +41,7 @@ class ProgressBar private $stepWidth; private $percent = 0.0; private $formatLineCount; - private $messages; + private $messages = array(); private $overwrite = true; private static $formatters; @@ -139,6 +139,16 @@ class ProgressBar return isset(self::$formats[$name]) ? self::$formats[$name] : null; } + /** + * Associates a text with a named placeholder. + * + * The text is displayed when the progress bar is rendered but only + * when the corresponding placeholder is part of the custom format line + * (by wrapping the name with %). + * + * @param string $message The text to associate with the placeholder + * @param string $name The name of the placeholder + */ public function setMessage($message, $name = 'message') { $this->messages[$name] = $message;