I have a controller class HomeController
with a particular method to get the Entity Manager
.:
protected function getImageManager()
{
if(!isset($_SESSION)) session_start();
if(isset($_SESSION['id']))
{
if($em = $this->getDoctrine()->getEntityManager()) return $em;
}
return false;
}
and it works when I use it inside HomeController
. But when I extend the controller and try to use this method I get an error: Fatal error: Call to a member function has() on a non-object in /home/xxxx/webDir/project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php on line 191
This is how I use this method inside HomeController
and the extended controller:
if($em = $this->getImageManager())
...
This is how I extend HomeController
:
namespace MSD\HomeBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use MSD\HomeBundle\Entity\Imagen as Imagen;
use MSD\HomeBundle\Controller\HomeController as HomeController;
class ImageTransController extends HomeController
{
function __construct()
{
if($em = $this->getImageManager()) return $this;
else $this->setError('Entity Manager error');
}
}
Any idea on what is going wrong?