Conversation
Templating isn't a service in Symfony 4+ (even after `composer req templating`), so probably we're looking for the twig service. The Router service isn't public and can therefor not be called from the container: ``` Information for Service "router.default" ======================================== ---------------- ----------------------------------------------- Option Value ---------------- ----------------------------------------------- Service ID router.default Class Symfony\Bundle\FrameworkBundle\Routing\Router Tags - Calls setConfigCacheFactory Public no Synthetic no Lazy no Shared yes Abstract no Autowired no Autoconfigured no ---------------- ----------------------------------------------- ```
|
Maybe it's time to remove the Accessing the Container Directly section entirely. @weaverryan what do you think? |
|
Yea, I agree: we should remove this section entirely. Could you do that @TheDevilOnLine? |
Removed "Accessing the Container Directly" section, as this way of work is currently deprecated.
|
@weaverryan Done. Can you guys do the squashing when doing the merge? Want me to check the rest of the documentation for these kind of container usage as well? |
|
@TheDevilOnLine Yep, no worries - we'll handle the squashing.
YES! I was literally just thinking this as I opened up your PR. There probably are a few legit cases still, but yea, we need to check all the docs to be sure. Thanks! |
…jection over Container. Includes changes from PR symfony#8985
|
I've went over the documentation and checked all instances containing The only thing I didn't know for sure (which might improve the documentation), is if there's a way to get a Doctrine EntityManager, other than the default one, through dependency injection. If this is possible, I think it's a good idea to add this information to multiple_entity_managers.rst as well I think the only other way is to inject the complete doctrine service, and call |
|
@TheDevilOnLine thanks for updating all this and congrats on your first contribution to Symfony Docs! |
… javiereguiluz) This PR was merged into the 4.0 branch. Discussion ---------- Removed invalid examples Templating isn't a service in Symfony 4+ (even after `composer req templating`), so probably we're looking for the twig service. The Router service isn't public and can therefor not be called from the container: ``` $ php bin/console debug:container router // This service is an alias for the service router.default Information for Service "router.default" ======================================== ---------------- ----------------------------------------------- Option Value ---------------- ----------------------------------------------- Service ID router.default Class Symfony\Bundle\FrameworkBundle\Routing\Router Tags - Calls setConfigCacheFactory Public no Synthetic no Lazy no Shared yes Abstract no Autowired no Autoconfigured no ---------------- ----------------------------------------------- ``` Commits ------- 3492028 Use controller method injection instead of the constructor f9091b0 Updated documentation to reflect best practice of using Dependency Injection over Container. Includes changes from PR #8985 18e6d9e Removed "Accessing the Container Directly" 89e38ef Removed invalid examples
Templating isn't a service in Symfony 4+ (even after
composer req templating), so probably we're looking for the twig service.The Router service isn't public and can therefor not be called from the container: