You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Documentation says: Another possibility is to use the #[Target] attribute. By using this attribute on the argument you want to autowire, you can define exactly which service to inject by using its alias.
According to this documentation and having the following code
interface ProviderInterface {}
class ProviderA implement ProviderInterface {}
class ProviderB implement ProviderInterface {}
i define alias for service in services
correct_provider:
alias: App\ProviderA
and try to inject it via #[Target] attribute
class JobService {
public function __construct(#[Target('correct_provider')] ProviderInterface $provider) {}
}
but this don't work.
After viewing the source code, I realized that this should not work.
I think this line in the documentation is misleading.
The text was updated successfully, but these errors were encountered:
Documentation says: Another possibility is to use the #[Target] attribute. By using this attribute on the argument you want to autowire, you can define exactly which service to inject by using its alias.
According to this documentation and having the following code
i define alias for service in services
and try to inject it via
#[Target]
attributebut this don't work.
After viewing the source code, I realized that this should not work.
I think this line in the documentation is misleading.
The text was updated successfully, but these errors were encountered: