Skip to content

Commit 86ef304

Browse files
committed
add note on service parameters regarding ScopeWideningInjectionException
1 parent 9afb147 commit 86ef304

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

book/service_container.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,15 @@ looks up the value of each parameter and uses it in the service definition.
231231
232232
<argument type="string">http://symfony.com/?foo=%%s&bar=%%d</argument>
233233
234+
.. note::
235+
236+
It can be useful to pass other services in as arguments to your custom service.
237+
For example, you may want to pass in the `request` service as an argument.
238+
In these cases, you may receive a `ScopeWideningInjectionException`.
239+
To understand this problem better and learn how to solve it, refer to
240+
the cookbook article :doc:`/cookbook/service_container/scopes` for a
241+
few solutions.
242+
234243
The purpose of parameters is to feed information into services. Of course
235244
there was nothing wrong with defining the service without using any parameters.
236245
Parameters, however, have several advantages:

0 commit comments

Comments
 (0)