I got an annoying problem when I call this in a controller (ClientDomainController) :
$this->getDoctrine()->getManager();
I got this error :
Call to a member function has() on null
I looked the stack trace and see that :
$this->container is null
My controller extends from the Symfony Controller component :
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
The funny thing is that in an other controller (HomeController) I make the exact same things :
- Extend from Controller (the exact same class)
- Get Doctrine
- Get the EntityManager
- Use the manager
And this without any error.
The only one difference between the HomeController and the ClientDomainController is that the second one is a service. So I wrote it in the services.yml file :
services:
client_domain:
class: AppBundle\Controller\ClientDomainController
Finally I tested many things like creating a constructor to my controller and adding this to the services.yml file (things that a never did to the functional one) :
arguments: [ 'doctrine.orm.entity_manager' ]
Does somebody can help me please ? :)
Have a nice day ;)
Aucun commentaire:
Enregistrer un commentaire