Array of services injection - #2
Conversation
|
Hi, thank you for this idea. What happens if I need services in that array in some specific order? How can I do it? Only by wiring them manually? What if I do not need to pass all services that implement SlugRepositoryInterface to SlugTrailService? I'm not sure, but this approach seems too magical to me. |
|
The idea came from Spring Framework, where IoC container can autowire About the latter question, the interface servers here as a marker - I can't think of any case where I would make service implement such interface and then wouldn't want to have it injected :) |
When array is "type hinted", autowiring looks if type is specified in doc comment and wires array of all matching services.
E.g.