@@ -95,11 +95,13 @@ option to include as many services as needed to it and add the
95
95
services :
96
96
app.command_handler_locator :
97
97
class : Symfony\Component\DependencyInjection\ServiceLocator
98
- tags : ['container.service_locator']
99
98
arguments :
100
99
-
101
100
App\FooCommand : ' @app.command_handler.foo'
102
101
App\BarCommand : ' @app.command_handler.bar'
102
+ # if you are not using the default service autoconfiguration,
103
+ # add the following tag to the service definition:
104
+ # tags: ['container.service_locator']
103
105
104
106
.. code-block :: xml
105
107
@@ -116,7 +118,11 @@ option to include as many services as needed to it and add the
116
118
<argument key =" App\FooCommand" type =" service" id =" app.command_handler.foo" />
117
119
<argument key =" App\BarCommand" type =" service" id =" app.command_handler.bar" />
118
120
</argument >
119
- <tag name =" container.service_locator" />
121
+ <!--
122
+ if you are not using the default service autoconfiguration,
123
+ add the following tag to the service definition:
124
+ <tag name="container.service_locator" />
125
+ -->
120
126
</service >
121
127
122
128
</services >
@@ -132,13 +138,20 @@ option to include as many services as needed to it and add the
132
138
133
139
$container
134
140
->register('app.command_handler_locator', ServiceLocator::class)
135
- ->addTag('container.service_locator')
136
141
->setArguments(array(array(
137
142
'App\FooCommand' => new Reference('app.command_handler.foo'),
138
143
'App\BarCommand' => new Reference('app.command_handler.bar'),
139
144
)))
145
+ // if you are not using the default service autoconfiguration,
146
+ // add the following tag to the service definition:
147
+ // ->addTag('container.service_locator')
140
148
;
141
149
150
+ .. versionadded :: 4.1
151
+ The service locator autoconfiguration was introduced in Symfony 4.1. In
152
+ previous Symfony versions you always needed to add the
153
+ ``container.service_locator `` tag explicitly.
154
+
142
155
.. note ::
143
156
144
157
The services defined in the service locator argument must include keys,
0 commit comments