-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Use variadics for autowiring tagged services #23608
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
Comments
See #22200 What about an additional !variadic / VariadicArgument. In the same spirit as !iterator / IteratorArgument. With tagged services it would look something like; '$arg': !variadic !tagged-services tag |
I was thinking about having injected tagged services without any extra code in |
That implies that we're able to compute a collection of |
Agree; to me the bare minimum is having extra config in services.yml, i dont see how it relates to autowiring at first. The only "auto" thing i can think of is some typehint sniffing, ie technically we could this; public function __construct(array $a, iterable $b, ...$c) { } '$a': ['@service', '@other_service']
'$b': ['@service', '@other_service']
'$c': ['@service', '@other_service'] I think that's intuitive, though magic-ish. I believe this conflicts with @nicolas-grekas concern;
But how i see it is; you configure a sequence; you ask for a sequence. Enough for DI to process :) |
Just as a side note, if I remember well, chaining tags (in Edit: it's indeed forbidden. See http://www.yaml.org/spec/1.2/spec.html#id2783797 for the reference. |
as explained, I'm 👎 |
Although a documentation doesn't describe it, tagged services can be injected via
In all of cases I worked, a service would ever accept only one type of tagged services. Can this be used to have services autowired like this:
This way user would not have to write compiler pass, giving better experience. The con is lack of injecting multiple tagged services but I don't think users do it anyway.
The text was updated successfully, but these errors were encountered: