How to override EntityManager in ZF2
MyEntityManager extends \Doctrine\ORM\EntityManager {
}
So after using
$this->getServiceLocator()->get('Doctrine\ORM\EntityManager')
or
$this->getServiceLocator()->get('doctrine.entitymanager.orm_default')
I will get MyEntityManager.
Edit In comments I also asked about How to create aliases (shortcuts) for entity namespaces.
getRepository('Application\Entity\Some\Very\Nested\MyEntity')
getRepository('NestedShortcut:MyEntity')
Check this answer. That is what you want right?
To answer your namespace question:
$config = $entityManager->getConfiguration();
$config->addEntityNamespace('MyNested', 'Application\Entity\Some\Very\Nested');
$myNestedEntity = $entityManager->getRepository('MyNested:Entity');
Beware of the semicolon :
instead of the slash \