无法自动装配供应商服务:没有类型提示,您应该明确配置其值。

huangapple go评论136阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年8月10日 20:38:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76875812.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定