Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Console] Prevent fatal error when calling Command::getHelper without helperSet#18635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| publicfunctiongetHelper($name) | ||
| { | ||
| if (null ===$this->helperSet) { | ||
| thrownewLogicException(sprintf('Unable to retrieve helper "%s" because there is no HelperSet defined for this command. Did you forget to call %s#setHelperSet()?',$name,get_class($this))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
If I'm right, in Symfony we usually use theClass::method syntax instead ofClass#method. So%s#setHelperSet() should be%s::setHelperSet() in this error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks! Fixed
6b99f20 to50816e2Comparenicolas-grekas commentedApr 27, 2016
Could be applied on 2.3 also as bug fix. |
javiereguiluz commentedApr 28, 2016
👍 ... and I agree about merging it on 2.3. |
| publicfunctiongetHelper($name) | ||
| { | ||
| if (null ===$this->helperSet) { | ||
| thrownewLogicException(sprintf('Unable to retrieve helper "%s" because there is no HelperSet defined for this command. Did you forget to call %s::setHelperSet()?',$name,get_class($this))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The message can be confusing as you usually do not set the helper set directly on the command, but configure it for the application instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@xabbuh I simplified it by removing theDid you forget... part, let me know if you think that something like:
Did you forget to set an application for your command via Command::setApplication()? You can also set an HelperSet directly from your command using Command::setHelperSet().
Could be helpful. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The first part (setting the application) can as well be related to the command not being registered at the application (which will then set itself on the command).
Maybe something like:
Did you forget to add your command to the application or to set the application on the command using the setApplication() method? You can also set the HelperSet directly using the setHelperSet() method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@xabbuh Updated
c232ecb to6045a23Compare…Helper() without helperSetUse Command::setHelperSet rather than Command#setHelperSet in exception msgSimplify exception messageAdd DidYouForget to exception msg
6045a23 toede4d92Comparefabpot commentedMay 13, 2016
Thank you@chalasr. |
…per without helperSet (chalasr)This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes#18635).Discussion----------[Console] Prevent fatal error when calling Command::getHelper without helperSet| Q | A| ------------- | ---| Branch? | master| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#18619| License | MIT| Doc PR | n/aPatch attached to#18619Commits-------31285c2 [Console][#18619] Prevent fatal error when calling Command#getHelper() without helperSet
Uh oh!
There was an error while loading.Please reload this page.
Patch attached to#18619