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

Commitc7ea0cf

Browse files
committed
Documented the service locator autoconfiguration
1 parentcfed0b8 commitc7ea0cf

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

‎service_container/service_locators.rst‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,13 @@ option to include as many services as needed to it and add the
9595
services:
9696
app.command_handler_locator:
9797
class:Symfony\Component\DependencyInjection\ServiceLocator
98-
tags:['container.service_locator']
9998
arguments:
10099
-
101100
App\FooCommand:'@app.command_handler.foo'
102101
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']
103105
104106
..code-block::xml
105107
@@ -116,7 +118,11 @@ option to include as many services as needed to it and add the
116118
<argumentkey="App\FooCommand"type="service"id="app.command_handler.foo" />
117119
<argumentkey="App\BarCommand"type="service"id="app.command_handler.bar" />
118120
</argument>
119-
<tagname="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+
-->
120126
</service>
121127
122128
</services>
@@ -132,13 +138,20 @@ option to include as many services as needed to it and add the
132138
133139
$container
134140
->register('app.command_handler_locator', ServiceLocator::class)
135-
->addTag('container.service_locator')
136141
->setArguments(array(array(
137142
'App\FooCommand' => new Reference('app.command_handler.foo'),
138143
'App\BarCommand' => new Reference('app.command_handler.bar'),
139144
)))
145+
// if you are not using the default service autoconfiguration,
146+
// add the following tag to the service definition:
147+
// ->addTag('container.service_locator')
140148
;
141149
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+
142155
..note::
143156

144157
The services defined in the service locator argument must include keys,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp