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] Fix ability to disable lazy commands#25030
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
| * | ||
| * @throws CommandNotFoundException When given command name does not exist | ||
| */ | ||
| publicfunctionget($name) |
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.
has() is affected also, which might simplify get() as such
if (!$this->has($name)) {throw...;}$command =$this->commands[$name];
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.
Callinghas() should not initialize the command if it exists to me (onlyget() should do), so unless I'm mistaken, making it return false because!$this->get($name)->isEnabled() would be wrong
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.
well.. for non-lazy commands has() returns false in case it's disabled. I dont see a real reason why that wouldnt apply to lazy commands.
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.
I agree, just feel bad to load beforeget() :)
@ogizanagi agree forApplication::has() callingCommandLoaderInterface::get()?
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.
Yes, it looks the right thing to do to me regarding the existing functional.
8392b1a to3b995e5Compare| $commands =$this->commands; | ||
| foreach ($this->commandLoader->getNames()as$name) { | ||
| if (!isset($commands[$name])) { |
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.
what about
if (!isset($commands[$name]) &&$this->has($name)) {$commands[$name] =$this->get($name);}
looks weird, but avoids repeating isEnabled logic here and there.
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.
👍 done
3b995e5 to6787d8eComparenicolas-grekas commentedNov 19, 2017
Thank you@chalasr. |
This PR was merged into the 3.4 branch.Discussion----------[Console] Fix ability to disable lazy commands| Q | A| ------------- | ---| Branch? | 3.4| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | n/a| License | MIT| Doc PR | n/aProperly throw when running them and don't show them in the list, as for non lazy ones.Commits-------6787d8e [Console] Fix disabling lazy commands
Uh oh!
There was an error while loading.Please reload this page.
Properly throw when running them and don't show them in the list, as for non lazy ones.