我试图按照_481584覆盖服务定义 . 这是我的配置:

//services.yaml

services:
    # default configuration for services in *this* file
    _defaults:
        autowire: true      # Automatically injects dependencies in your services.
        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
        public: false       # Allows optimizing the container by removing unused services; this also means
                            # fetching services directly from the container via $container->get() won't work.
                            # The best practice is to be explicit about your dependencies anyway.

    # makes classes in src/ available to be used as services
    # this creates a service per class whose id is the fully-qualified class name
    App\:
        resource: '../src/*'
        exclude: '../src/{Entity,Migrations,Tests}'

    # controllers are imported separately to make sure services can be injected
    # as action arguments even if you don't extend any base controller class
    App\Controller\:
        resource: '../src/Controller'
        tags: ['controller.service_arguments']

    # add more service definitions when explicit configuration is needed
    # please note that last definitions always *replace* previous ones

imports:
    - {resource: 'clients.yaml'}

//clients.yaml

services:

    App\Api\Client\AbstractClient:
        abstract: true
        arguments:
            - '@serializer'
            - '@httplug.client.app'

    App\Api\Client\MyClient:
        parent: App\Api\Client\AbstractClient
        calls:
            - [setApiHost, ['%client.api_url%']]

如您所见,我有两个类,其中一个是抽象父类 .

这似乎是正确设置(成功覆盖):

Information for Service "App\Api\Client\AbstractClient"
=======================================================

 ---------------- ------------------------------------------ 
  Option           Value                                     
 ---------------- ------------------------------------------ 
  Service ID       App\Api\Client\AbstractClient             
  Class            App\Api\Client\AbstractClient             
  Tags             -                                         
  Public           yes                                       
  Synthetic        no                                        
  Lazy             no                                        
  Shared           yes                                       
  Abstract         yes                                       
  Autowired        no                                        
  Autoconfigured   no                                        
  Arguments        Service(serializer)                       
                   Service(httplug.client.app.http_methods)

这个类说它已经自动装配和自动配置,但是它(正确地)继承了我的 AbstractClient 中的参数,但它没有实现任何setter注入定义!

Information for Service "App\Api\Client\MyClient"
=========================================================

 ---------------- ------------------------------------------ 
  Option           Value                                     
 ---------------- ------------------------------------------ 
  Service ID       App\Api\Client\MyClient           
  Class            App\Api\Client\MyClient           
  Tags             -                                         
  Public           no                                        
  Synthetic        no                                        
  Lazy             no                                        
  Shared           yes                                       
  Abstract         no                                        
  Autowired        yes                                       
  Autoconfigured   yes                                       
  Arguments        Service(serializer)                       
                   Service(httplug.client.app.http_methods)

有人可以指导我为什么我的孩子 class 没有被正确覆盖?