无法绑定服务字符串参数

时间:2019-10-21 09:26:28

标签: service symfony-3.4

我正在尝试将Parameters.yml文件中的googleApiKey绑定到我的geoLocationService,但它一直在说:

Cannot autowire service "CoreBundle\Service\GeoLocationService": argument "$googleApiKey" of method "__construct()" is type-hinted "string", you should configure its value explicitly.

我尝试了许多通过搜索找到的配置变体,但没有任何效果。

GeoLocationService

public function __construct(EntityManager $entityManager, string $googleApiKey)

Service.yml

CoreBundle\Service\GeoLocationService:
    arguments:
        $googleApiKey: '%google_api_key%'

0 个答案:

没有答案