Skip to content

Commit 41670b0

Browse files
committed
[symfony#5922] Tweaks thanks to reviewers
1 parent 93a08f3 commit 41670b0

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Diff for: cookbook/map.rst.inc

+1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@
193193

194194
* :doc:`/cookbook/service_container/index`
195195

196+
* :doc:`/cookbook/service_container/shared`
196197
* :doc:`/cookbook/service_container/scopes`
197198
* :doc:`/cookbook/service_container/compiler_passes`
198199
* (Event Dispatcher) :doc:`/cookbook/event_dispatcher/event_listener`

Diff for: cookbook/service_container/shared.rst

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. index::
22
single: Service Container; Shared Services
33

4-
How to Define Not Shared Services
4+
How to Define Non Shared Services
55
=================================
66

77
.. versionadded:: 2.8
@@ -10,7 +10,7 @@ How to Define Not Shared Services
1010

1111
In the service container, all services are shared by default. This means that
1212
each time you retrieve the service, you'll get the *same* instance. This is
13-
often the behaviour you want, but in some cases, you might want to always get a
13+
often the behavior you want, but in some cases, you might want to always get a
1414
*new* instance.
1515

1616
In order to always get a new instance, set the ``shared`` setting to ``false``
@@ -20,6 +20,7 @@ in your service definition:
2020

2121
.. code-block:: yaml
2222
23+
# app/config/services.yml
2324
services:
2425
app.some_not_shared_service:
2526
class: ...
@@ -28,16 +29,20 @@ in your service definition:
2829
2930
.. code-block:: xml
3031
32+
<!-- app/config/services.xml -->
3133
<services>
3234
<service id="app.some_not_shared_service" class="..." shared="false" />
3335
</services>
3436
3537
.. code-block:: php
3638
39+
use Symfony\Component\DependencyInjection\Definition;
40+
41+
// app/config/services.php
3742
$definition = new Definition('...');
3843
$definition->setShared(false);
3944
4045
$container->setDefinition('app.some_not_shared_service', $definition);
4146
4247
Now, whenever you call ``$container->get('app.some_not_shared_service')`` or
43-
inject this service, you'll recieve a new instance.
48+
inject this service, you'll receive a new instance.

0 commit comments

Comments
 (0)