-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Fix deprecations for commands while maintian lazyness #849
Fix deprecations for commands while maintian lazyness #849
Conversation
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
#[AsCommand(name: 'sonata:classification:fix-context', description: 'Generate the default context if none defined and attach the context to all elements')] |
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 think this is the correct way to avoid this deprecation, wdyt @VincentLanglet ? In SonataAdminBundle we fixed it different but to me this is more correct since the attribue only gets used on Symfony 6.1, and the older versions can maintain what they have for 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 prefer this solution over sonata-project/SonataBlockBundle#1075 or (the SonataAdmin PR).
So the attribute solve the deprecation even if the static property is still used ?
Is there a reason to not doing this on Admin/BlockBundle or can we update the code too ?
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.
We can update that code too.
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
#[AsCommand(name: 'sonata:classification:fix-context', description: 'Generate the default context if none defined and attach the context to all elements')] |
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 prefer this solution over sonata-project/SonataBlockBundle#1075 or (the SonataAdmin PR).
So the attribute solve the deprecation even if the static property is still used ?
Is there a reason to not doing this on Admin/BlockBundle or can we update the code too ?
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'm fine with this way too, I did that way to not have to change code when dropping versions.
final class FixContextCommand extends Command | ||
{ | ||
// TODO: Remove static properties when support for Symfony < 6.0 is dropped. |
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 guess this can be removed when dropping support for Symfony < 5.4
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 attribute was introduced at 6.0. So it is better to remove both at 6.0.
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.
https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Console/Attribute/AsCommand.php Looks like it was already in 5.4
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, and maybe is not correct documented, but the change where they make the AsCommand load lazy is on 6.0
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.
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 thought it was because I read it in https://symfony.com/blog/new-in-symfony-5-3-lazy-command-description
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.
Seems like you are right even though it is not documented. Will try to update those indications on next pR.
Can you do the PR for SonataAdmin and SonataBlock ? @jordisala1991 |
Yes, you do know if there are other bundles with commands? |
Only |
Subject
I am targeting this branch, because this is BC.
Changelog