public function getEntityManager()
{
if (!$this->em) {
$this->em = call_user_func($this->factory);
if (!$this->em instanceof EntityManager) {
throw new \LogicException('Factory supplied to LazyEntityManager must return implementation of EntityManager.');
}
}
return $this->em;
}