-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Handle 'hidden' param from AsCommand attribute #41547
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
Handle 'hidden' param from AsCommand attribute #41547
Conversation
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.
Looks good to me except my comment
This patch doesn't fix the root issue. If you inspect the dumped container for example, you'll see that the command is correctly registered as hidden. |
$isHidden = $attribute[0]->newInstance()->hidden; | ||
} | ||
|
||
return $this->hidden || $isHidden; |
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.
For reviewers (and for the author): this patch cannot be correct, because it makes the attribute a mandatory piece of configuration that cannot be ignored. This is against the root principles of attributes, which should be purely declarative.
Note that past some issue with registering commands, there is another one: when the |
As said @nicolas-grekas without DI, the command name is not parsed when the |
After more tests this morning, I've discovered that AsCommand attribute works fine with CI. I just didn't know that this attribute needed to clear the cache to work. My bad. I'll close this PR as it is wrong and push my fix for the usage without CI in another one. |
@yoannrenard the need to clear cache when changing attributes is caused by #39988 |
Thanks for the information @stof |
This PR was merged into the 5.3 branch. Discussion ---------- [Console] Fix using #[AsCommand] without DI | Q | A | ------------- | --- | Branch? | 5.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #41547 | License | MIT | Doc PR | - Commits ------- c4357ea [Console] Fix using #[AsCommand] without DI
The recently introduced
AsCommand
attribute works like a charm (as much as the whole 5.3 release 👌). Thanks a lot for that!Though, it seems that the
hidden
property has been forgotten, whether one set it or not the command only checks the$this->hidden
value set from theconfigure()
method.For example:
When I run
bash bin/console list app
I getI implemented a fix inspired by the
$name
/$description
properties.