Skip to content

Commit 8c148dd

Browse files
committed
minor #9505 Documented the service locator autoconfiguration (javiereguiluz)
This PR was merged into the master branch. Discussion ---------- Documented the service locator autoconfiguration This fixes #9374. Commits ------- c7ea0cf Documented the service locator autoconfiguration
2 parents 4d8e66a + c7ea0cf commit 8c148dd

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
<argument key="App\FooCommand" type="service" id="app.command_handler.foo" />
117119
<argument key="App\BarCommand" type="service" id="app.command_handler.bar" />
118120
</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+
-->
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)