public function getEntityManager()
 {
     $options = $this->getOptions();
     if (null === $this->_entityManager) {
         $config = $this->getConfig();
         if (isset($options['autoGenerateProxyClasses'])) {
             $config->setAutoGenerateProxyClasses((bool) $options['autoGenerateProxyClasses']);
         }
         if (isset($options['sqlLogger']) && $options['sqlLogger'] != null) {
             if (!class_exists($options['sqlLogger'])) {
                 throw new Zend_Application_Resource_Exception("Sql logger class not found");
             }
             $config->setSQLLogger(new $options['sqlLogger']());
         }
         $em = \Doctrine\ORM\EntityManager::create($this->_connectionOptions, $config);
         $em->getEventManager()->addEventSubscriber(new \Doctrine\DBAL\Event\Listeners\MysqlSessionInit('utf8', 'utf8_unicode_ci'));
         $this->_entityManager = $em;
     }
     if (isset($options['isDefaultEntityManager']) && $options['isDefaultEntityManager'] == true) {
         \Service\Doctrine\Context::setDefaultEntityManager($this->_entityManager);
     }
     return $this->_entityManager;
 }