Exemplo n.º 1
0
 public function postModulesLoadsListener(\Zend\Module\ModuleEvent $event)
 {
     /** @var $cl \Zend\Module\Listener\ConfigMerger */
     $cl = $event->getConfigListener();
     $config = $cl->getMergedConfig(false);
     $this->config = array_merge($this->config, isset($config[__NAMESPACE__]) ? $config[__NAMESPACE__] : array());
 }
Exemplo n.º 2
0
 /**
  * Registers annotations required for the Doctrine AnnotationReader
  *
  * @param  ModuleEvent $e
  * @throws RuntimeException
  */
 public function registerAnnotations(ModuleEvent $e)
 {
     $config = $e->getConfigListener()->getMergedConfig();
     $config = $config['doctrine_orm_module'];
     if ($config->use_annotations) {
         $annotationsFile = false;
         if (isset($config->annotation_file)) {
             $annotationsFile = realpath($config->annotation_file);
         }
         if (!$annotationsFile) {
             // Trying to load DoctrineAnnotations.php without knowing its location
             $annotationReflection = new ReflectionClass('Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver');
             $annotationsFile = realpath(dirname($annotationReflection->getFileName()) . '/DoctrineAnnotations.php');
         }
         if (!$annotationsFile) {
             throw new RuntimeException('Failed to load annotation mappings, check the "annotation_file" setting');
         }
         AnnotationRegistry::registerFile($annotationsFile);
     }
     if (!class_exists('Doctrine\\ORM\\Mapping\\Entity', true)) {
         throw new RuntimeException('Doctrine could not be autoloaded: ensure it is in the correct path.');
     }
 }