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 support for autowiring services as closures using attributes#49628
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
377e267 todc3f5e7CompareNeirda24 commentedMar 7, 2023
Would this also be supported through yaml auto wiring ? |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
dc3f5e7 to540b0c8Compare#[Autowire]540b0c8 toa355993Comparenicolas-grekas commentedMar 8, 2023
Thanks for the feedback. PR (and description) updated with two new attributes: |
a355993 to9869327Comparenicolas-grekas commentedMar 8, 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.
GromNaN 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.
This is much more expressive and self-documented.
Neirda24 commentedMar 8, 2023
nicolas-grekas commentedMar 9, 2023
Merging as this blocks other PRs right now, but feel free to review after merge of course! |
…edLocator]` on controller arguments (HypeMC)This PR was merged into the 6.3 branch.Discussion----------[HttpKernel] Add tests for `#[TaggedIterator]` & `#[TaggedLocator]` on controller arguments| Q | A| ------------- | ---| Branch? | 6.3| Bug fix? | no| New feature? | no| Deprecations? | no| Tickets |Fix#49083| License | MIT| Doc PR | -~~I think this doesn't qualify as a bug fix, but an improvement. If I'm wrong please let me know.~~#49628 fixed the issue, this PR only adds tests now.Commits-------121e072 [DependencyInjection] Add tests for #[TaggedIterator] & #[TaggedLocator] on controller arguments
…avor of `#[AutowireDecorated]` (nicolas-grekas)This PR was merged into the 6.3 branch.Discussion----------[DependencyInjection] Deprecate `#[MapDecorated]` in favor of `#[AutowireDecorated]`| Q | A| ------------- | ---| Branch? | 6.3| Bug fix? | no| New feature? | no| Deprecations? | yes| Tickets | -| License | MIT| Doc PR | -`#[Map*]` are for controller argument resolvers.`#[Autowire*]` should be used for autowiring (see#49628).We could also rename `#[TaggedLocator]` and `#[TaggedIterator]` but I feel like the need is less obvious and the cost more important.Commits-------b653adf [DependencyInjection] Deprecate `#[MapDecorated]` in favor of `#[AutowireDecorated]`
Uh oh!
There was an error while loading.Please reload this page.
When dealing with laziness on the consumer side, a common pattern is to wrap a heavy service in a closure and call it only when needed.
This PR adds attribute
#[AutowireServiceClosure]for this purpose:It also adds support for turning callables into closures with a new
#[AutowireCallable]attribute:Of course, this fully leverages autowiring aliases, so that instead of "foo", you can use
MyInterface::class.