Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[DependencyInjection] Add#[AutowireIterator] attribute and improve#[AutowireLocator]#51832
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
8b9073c toed3efdaCompareUh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
17a9a15 to8ed9318Comparenicolas-grekas commentedOct 4, 2023
PR updated and ready. Big Hurray to@kbond for the tests 🙏 🤗 |
KerianMM commentedOct 5, 2023
TaggedIterator and TaggedLocator attributes are they still use full? |
nicolas-grekas commentedOct 5, 2023
@KerianMM that's an open question. I see no hurry in deprecating them, I'd be fine waiting for 7.1. |
7bb9a9e to38c48efCompareUh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/DependencyInjection/Attribute/AutowireIterator.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
stof commentedOct 5, 2023
Why not improving the existing attributes instead of adding new ones ? |
src/Symfony/Component/DependencyInjection/Attribute/AutowireLocator.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
38c48ef toc262b32Comparenicolas-grekas commentedOct 5, 2023
Because I think it's important to push the |
chalasr commentedOct 5, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
👍 to do it on 7.1 and give time to people having them since 5.3. The docs should probably recommend the new ones asap though |
OskarStark commentedOct 6, 2023
I updated the syntax for |
OskarStark commentedOct 6, 2023
Can you add a code example please? Thanks |
nicolas-grekas commentedOct 6, 2023
What's in ServiceSubscriberInterface:
|
OskarStark commentedOct 6, 2023
Updated |
c262b32 tofe8d9dcComparefe8d9dc toa87f2e0Comparenicolas-grekas commentedOct 6, 2023
Thank you@kbond. |
…ator]` and add `#[AutowireIterator]` (OskarStark)This PR was squashed before being merged into the 6.4 branch.Discussion----------[DependencyInjection] Update syntax for `#[AutowireLocator]` and add `#[AutowireIterator]`cc `@kbond`Waiting code merge*symfony/symfony#51832Fixes#18997Commits-------528cbda [DependencyInjection] Update syntax for `#[AutowireLocator]` and add `#[AutowireIterator]`
| "symfony/http-client-contracts":"<2.5", | ||
| "symfony/mailer":"<5.4", | ||
| "symfony/messenger":"<5.4", | ||
| "symfony/service-contracts":"<3.2", |
bendaviesOct 11, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
@kbond why was this added? is there a way to remove this conflict?
this makes it not possible for us to upgrade to symfony 6.4 because this forces a requirement forpsr/container ^2.0, and we are still on v1 because the latest version oflaminas/laminas-servicemanager requires v1:
https://github.com/laminas/laminas-servicemanager/blob/3.23.x/composer.json#L26
this is sort of the same issue asapi-platform/core#5811
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.
Sorry@kbond, tagged you as it looked like your commit.
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.
This is needed because the test case uses the $type argument of SubscribedService, which exists since 3.2.
PR welcome to change the test case and relax this.
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.
thanks
| if ($typeinstanceof SubscribedService) { | ||
| $key =$type->key ??$key; | ||
| $attributes =$type->attributes; |
bendaviesOct 12, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
symfony/dependency-injection requires"symfony/service-contracts": "^2.5|^3.0, butattributes,nullable andtype are not defined onSubscribedService in until 3.2.
is this a mistake?
…d `#[TaggedLocator]` (GromNaN)This PR was merged into the 7.1 branch.Discussion----------[DependencyInjection] Deprecate `#[TaggedIterator]` and `#[TaggedLocator]`| Q | A| ------------- | ---| Branch? | 7.1| Bug fix? | no| New feature? | no| Deprecations? | yes| Issues | Planned in#51832| License | MIT`#[TaggedIterator]` and `#[TaggedLocator]` attributes are replaced by `#[AutowireIterator]` and `#[AutowireLocator]`, for naming consistency with all `#[Autowire*]` attributes.Commits-------4bc6bed Deprecate #[TaggedIterator] and #[TaggedLocator]
…#[TaggedLocator]` attributes (GromNaN)This PR was merged into the 8.0 branch.Discussion----------[DependencyInjection] Remove `#[TaggedIterator]` and `#[TaggedLocator]` attributes| Q | A| ------------- | ---| Branch? | 8.0| Bug fix? | no| New feature? | yes| Deprecations? | no| Issues | -| License | MITThe new attributes `#[AutowireLocator]` and `#[AutowireIterator]` were introduced in Symfony 6.4 by#51392 and#51832.These replace the previous attributes `#[TaggedIterator]` and `#[TaggedLocator]` which were introduced in Symfony 5.4 by#40406 and subsequently deprecated in 7.1 by#54371Commits-------c096714 Remove TaggedIterator and TaggedLocator attributes
Uh oh!
There was an error while loading.Please reload this page.
This PR is building on#51392 to add an
#[AutowireIterator]attribute and improve#[AutowireLocator].The new
#[AutowireIterator]attribute can be used to describe what#[AutowireLocator]can do, except that we get an iterator instead of a container.And
#[AutowireLocator]can now be used instead of#[TaggedLocator]:#[AutowireLocator('foo')]and done.In order to describe that you want a list of services, we cannot use named arguments anymore so we have to pass an array now:
#[AutowireLocator(['foo' => 'F', 'bar' => 'B'])]should be used instead of#[AutowireLocator(foo: 'F', bar: 'B')].Last but not least, this adds support for nesting
SubscribedServiceobjects in the list of described services. This provides feature-parity with what we can do when implementingServiceSubscriberInterface.I didn't deprecate
TaggedIteratornorTaggedLocator. We could, but maybe we should wait for 7.1?TODO:
PS: while writing this, I realize that we may merge both tags in one, and letAutowirePassdecide if it should build a locator or an iterator based on the type of the argument that has the attribute. We'd "just" need to find a name that'd work for that.