Closed
Description
Hello
I faced something strange.
I wanted to add a data collector on a service. So I made a decorator.
My initial file:
services:
_defaults:
autowire: true
autoconfigure: true
AppBundle\AgentProxy\:
resource: '../../../src/AgentProxy/*'
exclude:
- '../../../src/AgentProxy/**/Exception/*'
- '../../../src/AgentProxy/**/Model/*'
AppBundle\AgentProxy\ClientInterface: '@AppBundle\AgentProxy\Client'
So I blindly added
when@dev:
services:
AppBundle\AgentProxy\ClientCollector:
decorates: AppBundle\AgentProxy\ClientInterface
It does not work for 2 reasons
- Autowire does not work even if it's in the same file. I need to add
_defaults: { autowire: true}
in thewhen@dev
section - So I also added
autoconfigure: true
, but does not work. I need to manually tag the service.
The final configuration that works
services:
_defaults:
autowire: true
autoconfigure: true
AppBundle\AgentProxy\:
resource: '../../../src/AgentProxy/*'
exclude:
- '../../../src/AgentProxy/**/Exception/*'
- '../../../src/AgentProxy/**/Model/*'
AppBundle\AgentProxy\ClientInterface: '@AppBundle\AgentProxy\Client'
when@dev:
services:
_defaults:
autowire: true
autoconfigure: true # useless
AppBundle\AgentProxy\ClientCollector:
decorates: AppBundle\AgentProxy\ClientInterface
tags:
-
name: data_collector
id: 'AppBundle\AgentProxy\ClientCollector'