英文:
Cannot autowire vendor service: has no type-hint, you should configure its value explicitly
问题
在我的Symfony 6应用程序中,我试图在我的service.yaml
文件中使用依赖注入来绑定一些参数,但是出现了一个错误:
> 无法自动装配服务“Microsoft\BingAds\Auth\ServiceClient”:方法“__construct()”的参数“$serviceClientType”没有类型提示,您应该明确配置其值。
而在YAML文件中:
Microsoft\BingAds\Auth\ServiceClient:
autowire: true
问题在于它是供应商库包的一部分,所以我无法编辑它。
也许这不是必要的,但ServiceClient
类的构造函数看起来像这样:
public function __construct($serviceClientType, $authorizationData, $apiEnvironment, $options = array())
{
...
}
有人可以帮助我如何解决这个错误吗?
谢谢
英文:
In my Symfony 6 app, I am trying to use dependency injection within my service.yaml
file to bind some arguments but getting an error:
> Cannot autowire service "Microsoft\BingAds\Auth\ServiceClient": argument "$serviceClientType" of method "__construct()" has no type-hint, you should configure its value explicitly.
And in the YAML file:
Microsoft\BingAds\Auth\ServiceClient:
autowire: true
The problem with it is that it is a part of the vendor library package so I can not edit it.
Maybe it is not necessary but the ServiceClient
class constructor looks something like this:
public function __construct($serviceClientType, $authorizationData, $apiEnvironment, $options = array())
{
...
}
Can someone help with how to surpass this error?
Thanks
答案1
得分: 0
它说您不能使用自动装配,因为参数没有类型提示。因此,在service.yaml
中明确设置它:
Microsoft\BingAds\Auth\ServiceClient:
arguments:
$serviceClientType: YOUR_VALUE_HERE
$authorizationData: YOUR_VALUE_HERE
$apiEnvironment: YOUR_VALUE_HERE
英文:
It says you that autowiring doesn't work because arguments are not type-hinted. So set it explicitly in service.yaml
:
Microsoft\BingAds\Auth\ServiceClient:
arguments:
$serviceClientType: YOUR_VALUE_HERE
$authorizationData: YOUR_VALUE_HERE
$apiEnvironment: YOUR_VALUE_HERE
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论