Symfony:将对象(不是服务)注入服务构造函数

Symfony:将对象(不是服务)注入服务构造函数,symfony,Symfony,在服务的定义中,我希望将对象而不是服务作为服务参数构造函数传递 从config.yml: services: acme.services.exampleservice: class: Acme\ExampleBundle\Services\ExampleService arguments: entityManager: "@doctrine.orm.entity_manager" httpClient: \Example\Http\Clie

在服务的定义中,我希望将对象而不是服务作为服务参数构造函数传递

从config.yml:

services:
  acme.services.exampleservice:
    class:  Acme\ExampleBundle\Services\ExampleService
    arguments: 
        entityManager: "@doctrine.orm.entity_manager"
        httpClient: \Example\Http\Client\Client
请注意
httpClient
参数。这必须是
\Example\Http\Client\Client
类的实例

上述操作不起作用-字符串“\Example\Http\Client\Client”作为
httpClient
参数传递给服务


通过将
\Example\Http\Client\Client
的实例传递给服务构造函数来实现上述功能的语法是什么?

创建专用服务。这里写的是:

如果使用私有服务作为多个其他服务的参数,这将导致在内联完成私有服务的实例化时使用两个不同的实例(例如new PrivateFooBar())


您将无法从容器中检索专用服务。从外面看,它看起来就像你把一个普通的对象传递给了你服务的构造函数。

先生,你救了我一命!谢谢
services:
  acme.services.exampleservice:
    class:  Acme\ExampleBundle\Services\ExampleService
    arguments: 
        entityManager: "@doctrine.orm.entity_manager"
        httpClient: acme.services.httpClient

  acme.services.httpClient:
    class: Example\Http\Client\Client
    public: false