@@ -12,10 +12,11 @@ This entry is all about scopes, a somewhat advanced topic related to the
1212
1313 If you are trying to inject the ``request `` service, the simple solution
1414 is to inject the ``request_stack `` service instead and access the current
15- Request by calling the ``getCurrentRequest() `` method (see :ref: `book-container-request-stack `).
16- The rest of this entry talks about scopes in a theoretical and more advanced
17- way. If you're dealing with scopes for the ``request `` service, simply
18- inject ``request_stack ``.
15+ Request by calling the
16+ :method: `Symfony\\ Component\\ HttpFoundation\\ RequestStack::getCurrentRequest `
17+ method (see :ref: `book-container-request-stack `). The rest of this entry
18+ talks about scopes in a theoretical and more advanced way. If you're
19+ dealing with scopes for the ``request `` service, simply inject ``request_stack ``.
1920
2021Understanding Scopes
2122--------------------
@@ -35,7 +36,7 @@ also defines a third scope: ``request``. This scope is tied to the request,
3536meaning a new instance is created for each subrequest and is unavailable
3637outside the request (for instance in the CLI).
3738
38- An Example: client Scope
39+ An Example: Client Scope
3940~~~~~~~~~~~~~~~~~~~~~~~~
4041
4142Other than the ``request `` service (which has a simple solution, see the
@@ -92,13 +93,13 @@ when compiling the container. Read the sidebar below for more details.
9293 A service can of course depend on a service from a wider scope without
9394 any issue.
9495
95- Using a Service from a narrower Scope
96+ Using a Service from a Narrower Scope
9697-------------------------------------
9798
9899There are several solutions to the scope problem:
99100
100- * A) Use setter injection if the dependency is " synchronized"; (see
101- :ref: `using-synchronized-service `).
101+ * A) Use setter injection if the dependency is `` synchronized `` (see
102+ :ref: `using-synchronized-service `);
102103
103104* B) Put your service in the same scope as the dependency (or a narrower one). If
104105 you depend on the ``client_configuration `` service, this means putting your
@@ -107,13 +108,13 @@ There are several solutions to the scope problem:
107108* C) Pass the entire container to your service and retrieve your dependency from
108109 the container each time you need it to be sure you have the right instance
109110 -- your service can live in the default ``container `` scope (see
110- :ref: `passing-container `);
111+ :ref: `passing-container `).
111112
112113Each scenario is detailed in the following sections.
113114
114115.. _using-synchronized-service :
115116
116- A) Using a synchronized Service
117+ A) Using a Synchronized Service
117118~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
118119
119120.. versionadded :: 2.3
0 commit comments