-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -454,13 +454,15 @@ public function add(Command $command) | |||
public function get($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.
Calling has()
should not initialize the command if it exists to me (only get()
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 before get()
:)
@ogizanagi agree for Application::has()
calling CommandLoaderInterface::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
to
3b995e5
Compare
@@ -650,7 +647,9 @@ public function all($namespace = null) | |||
$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
to
6787d8e
Compare
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/a Properly throw when running them and don't show them in the list, as for non lazy ones. Commits ------- 6787d8e [Console] Fix disabling lazy commands
Properly throw when running them and don't show them in the list, as for non lazy ones.