Answer the question
In order to leave comments, you need to log in
How to call EntityManager in a controller which is defined as a service?
In a regular service, I passed the @doctrine.orm.entity_manager argument to the constructor and everything worked.
Now it took some methods in the controller to reuse, and I'm doing something wrong.
The documentation symfony.com/doc/current/cookbook/controller/servic... says
"Simply inject doctrine instead of fetching it from the container" on this. And there is no example.
How to do it right?
Answer the question
In order to leave comments, you need to log in
Now it took some methods in the controller to reuse
Read what Sergei Protko suggested to you .
services:
app.super_puper_controller:
class: AppBundle\Controller\BlackMagicController
calls:
- [setContainer, ["@services_container"]]
- [setOtherMethod, ["@router", "%my_parameter%"]]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question