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#[AutowireLocator] attribute#51392
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
Uh oh!
There was an error while loading.Please reload this page.
nicolas-grekas left a comment
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.
Love it, I didn't expect the implementation to be so simple :)
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.
derrabus commentedAug 16, 2023
In order to address the failing Psalm job, I've opened#51395. |
#[Locator] attribute#[AutowireLocator] attribute7d2e338 to0e0583fComparenicolas-grekas commentedAug 17, 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.
I'm wondering how we could make these work: #[AutowireLocator(['cache' =>newSubscribedService(type: CacheInterface::class: attributes: [newTarget('my.cache')]),'blobs' =>newTaggedLocator('blob'),)]ContainerInterface$container, Any idea? |
kbond commentedAug 17, 2023 • edited by nicolas-grekas
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by nicolas-grekas
Uh oh!
There was an error while loading.Please reload this page.
I thought that too! I was going to take a look at this possibility after this was merged. BTW, your example can't be an array, it needs to be: #[AutowireLocator( cache:newSubscribedService(type: CacheInterface::class: attributes: [newTarget('my.cache')]), blobs:newTaggedLocator('blob'),)]ContainerInterface$container, (just making sure you're ok with this syntax) |
nicolas-grekas commentedAug 21, 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.
I just noticed the failures on high+low deps, can you please have a look? |
kbond commentedAug 21, 2023
I believe the test suite will be fixed once merged because of the http-kernel's requirement on this |
Uh oh!
There was an error while loading.Please reload this page.
3028d76 to5fa830dComparenicolas-grekas commentedAug 21, 2023
Thank you@kbond. |
…ute and improve `#[AutowireLocator]` (nicolas-grekas, kbond)This PR was merged into the 6.4 branch.Discussion----------[DependencyInjection] Add `#[AutowireIterator]` attribute and improve `#[AutowireLocator]`| Q | A| ------------- | ---| Branch? | 6.4| Bug fix? | no| New feature? | yes| Deprecations? | no| Tickets | -| License | MITThis 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 `SubscribedService` objects in the list of described services. This provides feature-parity with what we can do when implementing `ServiceSubscriberInterface`.I didn't deprecate `TaggedIterator` nor `TaggedLocator`. We could, but maybe we should wait for 7.1?TODO:- [x] add tests - thanks `@kbond`!~PS: while writing this, I realize that we may merge both tags in one, and let `AutowirePass` decide 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.~Commits-------a87f2e0 [DependencyInjection] Add tests for `AutowireLocator`/`AutowireIterator`78018de [DependencyInjection] Add `#[AutowireIterator]` attribute and improve `#[AutowireLocator]`
…#[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.
The
AutowireLocatorattribute allows configuring service locators inline:You can customize the key and have optional services: