public function getEntityManager()
{
if ($this->em === NULL) {
$controller = $this->getActionController();
$bootstrap = $controller->getInvokeArg('bootstrap');
$doctrine = $bootstrap->getResource('doctrine');
$this->setEntityManager($doctrine->getEntityManager());
}
return $this->em;
}