Skip to content

[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

Merged
merged 1 commit into from
Nov 19, 2017

Conversation

chalasr
Copy link
Member

@chalasr chalasr commented Nov 19, 2017

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.

@@ -454,13 +454,15 @@ public function add(Command $command)
public function get($name)
Copy link
Contributor

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];

Copy link
Member Author

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

Copy link
Contributor

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.

Copy link
Member Author

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()?

Copy link
Contributor

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.

@@ -650,7 +647,9 @@ public function all($namespace = null)
$commands = $this->commands;
foreach ($this->commandLoader->getNames() as $name) {
if (!isset($commands[$name])) {
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 done

@chalasr chalasr force-pushed the disabled-lazy-command branch from 3b995e5 to 6787d8e Compare November 19, 2017 16:18
@nicolas-grekas
Copy link
Member

Thank you @chalasr.

@nicolas-grekas nicolas-grekas merged commit 6787d8e into symfony:3.4 Nov 19, 2017
nicolas-grekas added a commit that referenced this pull request Nov 19, 2017
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
@chalasr chalasr deleted the disabled-lazy-command branch November 19, 2017 19:03
This was referenced Nov 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants