Commit c9bad24
committed
minor #14819 Add warning about removed services (alexislefebvre)
This PR was squashed before being merged into the 4.4 branch.
Discussion
----------
Add warning about removed services
I was confused by the fact that the documentation explains:
> Finally, for the most rare edge-cases, Symfony includes a special container which provides access to all services, public and private. This special container is a service that can be get via the normal container
and the fact that the special container doesn't give access to the removed service.
So I added a tip in the documentation, taking inspiration from a Symfony article:
> Keep in mind that, because of how Symfony's service container work, unused services are removed from the container. This means that if you have a private service not used by any other service, Symfony will remove it and you won't be able to get it as explained in this article. The solution is to define the service as public explicitly so Symfony doesn't remove it.
Source: https://symfony.com/blog/new-in-symfony-4-1-simpler-service-testing
This is also consistent with the error message from Symfony: https://github.com/symfony/symfony/blob/3ffe5573e9dd045e157c6f17358c700fceae3feb/src/Symfony/Component/DependencyInjection/Container.php#L275
See also #12647 and symfony/symfony#30104
Commits
-------
e6a6c33 Add warning about removed services1 file changed
+6
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
590 | 590 | | |
591 | 591 | | |
592 | 592 | | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
593 | 599 | | |
594 | 600 | | |
595 | 601 | | |
| |||
0 commit comments