Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8d8c65e

Browse files
committed
Reword
1 parentbc5ef85 commit8d8c65e

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

‎service_container/service_subscribers_locators.rst‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,7 @@ Defining a Service Locator
244244

245245
To manually define a service locator, create a new service definition and add
246246
the ``container.service_locator`` tag to it. Use the first argument of the
247-
service definition to pass a collection of services to the service locator. If
248-
there is no id specified for the service it will inherit its external id.
247+
service definition to pass a collection of services to the service locator:
249248

250249
..configuration-block::
251250

@@ -259,6 +258,9 @@ there is no id specified for the service it will inherit its external id.
259258
-
260259
App\FooCommand:'@app.command_handler.foo'
261260
App\BarCommand:'@app.command_handler.bar'
261+
# if the element has no key, the ID of the original service is used
262+
'@app.command_handler.baz'
263+
262264
# if you are not using the default service autoconfiguration,
263265
# add the following tag to the service definition:
264266
# tags: ['container.service_locator']
@@ -275,8 +277,10 @@ there is no id specified for the service it will inherit its external id.
275277
276278
<serviceid="app.command_handler_locator"class="Symfony\Component\DependencyInjection\ServiceLocator">
277279
<argumenttype="collection">
278-
<argumentkey="App\FooCommand"type="service"id="app.command_handler.foo"/>
279-
<argumentkey="App\BarCommand"type="service"id="app.command_handler.bar"/>
280+
<argumentkey="App\FooCommand"type="service"id="app.command_handler.foo" />
281+
<argumentkey="App\BarCommand"type="service"id="app.command_handler.bar" />
282+
<!-- if the element has no key, the ID of the original service is used-->
283+
<argumenttype="service"id="app.command_handler.baz" />
280284
</argument>
281285
<!--
282286
if you are not using the default service autoconfiguration,
@@ -301,7 +305,9 @@ there is no id specified for the service it will inherit its external id.
301305
->setArguments([[
302306
'App\FooCommand' => new Reference('app.command_handler.foo'),
303307
'App\BarCommand' => new Reference('app.command_handler.bar'),
304-
]])
308+
// if the element has no key, the ID of the original service is used
309+
new Reference('app.command_handler.baz'),
310+
)))
305311
// if you are not using the default service autoconfiguration,
306312
// add the following tag to the service definition:
307313
// ->addTag('container.service_locator')
@@ -314,7 +320,7 @@ there is no id specified for the service it will inherit its external id.
314320

315321
..versionadded::4.2
316322

317-
The ability to add services without specifyingan id was introduced in
323+
The ability to add services without specifyingtheir id was introduced in
318324
Symfony 4.2.
319325

320326
..note::

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp