Skip to content

Commit a012eaf

Browse files
Reword
1 parent 2b5f165 commit a012eaf

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

service_container/service_subscribers_locators.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ Defining a Service Locator
247247

248248
To manually define a service locator, create a new service definition and add
249249
the ``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
-
263262
App\FooCommand: '@app.command_handler.foo'
264263
App\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 specifying an id was introduced in
325+
The ability to add services without specifying their id was introduced in
320326
Symfony 4.2.
321327

322328
.. note::

0 commit comments

Comments
 (0)