|
22 | 22 |
|
23 | 23 | .. _inlined-private-services:
|
24 | 24 |
|
25 |
| -In these cases, to get a minor performance boost, you can set the service |
26 |
| -to be *not* public (i.e. private): |
| 25 | +In these cases, to get a minor performance boost and ensure the service will not |
| 26 | +be retrieved directly from the container, you can set the service to be *not* |
| 27 | +public (i.e. private): |
27 | 28 |
|
28 | 29 | .. configuration-block::
|
29 | 30 |
|
@@ -54,18 +55,19 @@ to be *not* public (i.e. private):
|
54 | 55 | $definition->setPublic(false);
|
55 | 56 | $container->setDefinition('foo', $definition);
|
56 | 57 |
|
57 |
| -What makes private services special is that, if they are only injected once, |
58 |
| -they are converted from services to inlined instantiations (e.g. ``new PrivateThing()``). |
59 |
| -This increases the container's performance. |
| 58 | +What makes private services special is that, since the container knows that the |
| 59 | +service will never be requested from outside, it can optimize whether and how it |
| 60 | +is instanciated. This increases the container's performance. |
60 | 61 |
|
61 | 62 | Now that the service is private, you *should not* fetch the service directly
|
62 | 63 | from the container::
|
63 | 64 |
|
64 | 65 | $container->get('foo');
|
65 | 66 |
|
66 |
| -This *may or may not work*, depending on if the service could be inlined. |
67 |
| -Simply said: A service can be marked as private if you do not want to access |
68 |
| -it directly from your code. |
| 67 | +This *may or may not work*, depending on how the container as optimized the |
| 68 | +service instanciation and, even in the cases where it works, is |
| 69 | +deprecated. Simply said: A service can be marked as private if you do not want |
| 70 | +to access it directly from your code. |
69 | 71 |
|
70 | 72 | However, if a service has been marked as private, you can still alias it
|
71 | 73 | (see below) to access this service (via the alias).
|
|
0 commit comments