@@ -247,8 +247,7 @@ Defining a Service Locator
247247
248248To manually define a service locator, create a new service definition and add
249249the ``container.service_locator `` tag to it. Use the first argument of the
250- service definition to pass a collection of services to the service locator. If
251- there is no id specified for the service it will inherit its external id.
250+ service definition to pass a collection of services to the service locator:
252251
253252..configuration-block ::
254253
@@ -262,6 +261,9 @@ there is no id specified for the service it will inherit its external id.
262261 -
263262App\FooCommand :' @app.command_handler.foo'
264263App\BarCommand :' @app.command_handler.bar'
264+ # if the element has no key, the ID of the original service is used
265+ ' @app.command_handler.baz'
266+
265267# if you are not using the default service autoconfiguration,
266268# add the following tag to the service definition:
267269# tags: ['container.service_locator']
@@ -280,6 +282,8 @@ there is no id specified for the service it will inherit its external id.
280282 <argument type =" collection" >
281283 <argument key =" App\FooCommand" type =" service" id =" app.command_handler.foo" />
282284 <argument key =" App\BarCommand" type =" service" id =" app.command_handler.bar" />
285+ <!-- if the element has no key, the ID of the original service is used-->
286+ <argument type =" service" id =" app.command_handler.baz" />
283287 </argument >
284288<!--
285289 if you are not using the default service autoconfiguration,
@@ -304,6 +308,8 @@ there is no id specified for the service it will inherit its external id.
304308 ->setArguments(array(array(
305309 'App\FooCommand' => new Reference('app.command_handler.foo'),
306310 'App\BarCommand' => new Reference('app.command_handler.bar'),
311+ // if the element has no key, the ID of the original service is used
312+ new Reference('app.command_handler.baz'),
307313 )))
308314 // if you are not using the default service autoconfiguration,
309315 // add the following tag to the service definition:
@@ -316,7 +322,7 @@ there is no id specified for the service it will inherit its external id.
316322 ``container.service_locator `` tag explicitly.
317323
318324..versionadded ::4.2
319- The ability to add services without specifyingan id was introduced in
325+ The ability to add services without specifyingtheir id was introduced in
320326 Symfony 4.2.
321327
322328..note ::