bug #12806 [Console] Removed the use of $this->getHelperSet() as it is null by default (saro0h)

This PR was submitted for the 2.6 branch but it was merged into the 2.5 branch instead (closes #12806).

Discussion
----------

[Console] Removed the use of $this->getHelperSet() as it is null by default

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #12805
| License       | MIT
| Doc PR        | ~

Before:
![capture d ecran 2014-12-02 a 15 51 38](https://cloud.githubusercontent.com/assets/667519/5264798/303bf87a-7a3e-11e4-9b45-68e8a86bab60.png)

After:
![capture d ecran 2014-12-02 a 16 36 25](https://cloud.githubusercontent.com/assets/667519/5265299/b13190d6-7a41-11e4-9e68-d889ea290cae.png)

Commits
-------

111b194 Added information when an error occured during validation of an answer of a question
This commit is contained in:
Fabien Potencier 2014-12-08 09:28:22 +01:00
commit 99369a2b49
1 changed files with 7 additions and 1 deletions

View File

@ -355,7 +355,13 @@ class QuestionHelper extends Helper
$attempts = $question->getMaxAttempts();
while (null === $attempts || $attempts--) {
if (null !== $error) {
$output->writeln($this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'));
if (null !== $this->getHelperSet() && $this->getHelperSet()->has('formatter')) {
$message = $this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error');
} else {
$message = '<error>'.$error->getMessage().'</error>';
}
$output->writeln($message);
}
try {