8000 minor #9157 do never fetch private services from the container (xabbuh) · symfony/symfony-docs@e2c4a43 · GitHub
[go: up one dir, main page]

Skip to content

Commit e2c4a43

Browse files
committed
minor #9157 do never fetch private services from the container (xabbuh)
This PR was merged into the 2.7 branch. Discussion ---------- do never fetch private services from the container Explaining that private services can still be fetched from the container under certain circumstances does not look like a good idea. Not only is it hard to grasp for beginners to understand why this sometimes works. It also becomes a real problem when upgrading to Symfony 4 where all private services won't be retrievable from the container through service location. Commits ------- fedc522 do never fetch private services from the container
2 parents 3c94d1d + fedc522 commit e2c4a43

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

service_container/alias_private.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,11 @@ What makes private services special is that, if they are only injected once,
5757
they are converted from services to inlined instantiations (e.g. ``new PrivateThing()``).
5858
This increases the container's performance.
5959 6EB9

60-
Now that the service is private, you *should not* fetch the service directly
60+
Now that the service is private, you *must not* fetch the service directly
6161
from the container::
6262

6363
$container->get('foo');
6464

65-
This *may or may not work*, depending on if the service could be inlined.
6665
Simply said: A service can be marked as private if you do not want to access
6766
it directly from your code.
6867

0 commit comments

Comments
 (0)
0