Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
Open
Description
Description
I have multiple implementations for my interface. I want to inject the service typed by its interface + argument. Same ashttps://symfony.com/doc/current/service_container/autowiring.html#dealing-with-multiple-implementations-of-the-same-type but with attributes.
What do you guys think? I'd be able to create a PR if accepted.
Example
<?phpnamespaceFoo;useSymfony\Component\DependencyInjection\Attribute\AsAlias;#[AsAlias(argument:'one']finalclass MyAdapterClassOneimplements \Bar\MyInterface{// ...}#[AsAlias(argument:'two']finalclass MyAdapterClassTwoimplements \Bar\MyInterface{// ...}
<?phpnamespaceServices;finalclass MyService{publicfunction__construct(private\Bar\MyInterface$one)//MyAdapterClassOne class is injected { }}