I\'ve been trying to call Entity Manager
in a constructor:
function __construct()
{
$this->getDoctrine()->getEntityManager();
...
I see that you are trying to get the entity manager in the constructor of the controller, which is not the way to do so , unless you plan to define your controller as a service. which on this case, you need to use dependency injection to inject the service entity manager.
But in general the common way to use entity manager in a controller is simply by getting it using the following code:
$entityManager = $this->container->get('doctrine.orm.entity_manager');