Пример #1
0
        $classLoader = new \Doctrine\Common\ClassLoader($name, $path);
    } else {
        $classLoader = new \Doctrine\Common\ClassLoader($name);
    }
    $classLoader->register();
}
foreach ($entitiesPath as $name => $path) {
    $classLoader = new \Doctrine\Common\ClassLoader($name, $path);
    $classLoader->register();
}
// Setup Entity Manager
// ****************************************************************
$ormConfig = new \Doctrine\ORM\Configuration();
// custom zend form annotations
$annoReader = new \Doctrine\Common\Annotations\AnnotationReader();
$annoReader->setAutoloadAnnotations(true);
$annoReader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
$annoReader->setAnnotationNamespaceAlias('Awe\\Annotations\\', 'awe');
$annoDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($annoReader, $entitiesPath);
$ormConfig->setMetadataDriverImpl($annoDriver);
// logging
$ormConfig->setSQLLogger(new \Doctrine\DBAL\Logging\FileSQLLogger($logPath));
// caching
if (is_array($cacheType)) {
    $ormConfig->setQueryCacheImpl(new $cacheType['query']());
    $ormConfig->setMetadataCacheImpl(new $cacheType['metadata']());
} else {
    $ormConfig->setQueryCacheImpl(new $cacheType());
    $ormConfig->setMetadataCacheImpl(new $cacheType());
}
// proxies
 /**
  * Create default annotation reader for extensions
  *
  * @return \Doctrine\Common\Annotations\AnnotationReader
  */
 private function getDefaultAnnotationReader()
 {
     if (null === self::$defaultAnnotationReader) {
         if (version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>=')) {
             $reader = new \Doctrine\Common\Annotations\AnnotationReader();
             \Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('Gedmo\\Mapping\\Annotation', __DIR__ . '/../../');
             $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new ArrayCache());
         } elseif (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0RC4-DEV', '>=')) {
             $reader = new \Doctrine\Common\Annotations\AnnotationReader();
             \Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('Gedmo\\Mapping\\Annotation', __DIR__ . '/../../');
             $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
             $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new ArrayCache());
         } elseif (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0-BETA3-DEV', '>=')) {
             $reader = new \Doctrine\Common\Annotations\AnnotationReader();
             $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
             $reader->setIgnoreNotImportedAnnotations(true);
             $reader->setAnnotationNamespaceAlias('Gedmo\\Mapping\\Annotation\\', 'gedmo');
             $reader->setEnableParsePhpImports(false);
             $reader->setAutoloadAnnotations(true);
             $reader = new \Doctrine\Common\Annotations\CachedReader(new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache());
         } else {
             $reader = new \Doctrine\Common\Annotations\AnnotationReader();
             $reader->setAutoloadAnnotations(true);
             $reader->setAnnotationNamespaceAlias('Gedmo\\Mapping\\Annotation\\', 'gedmo');
             $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
         }
         self::$defaultAnnotationReader = $reader;
     }
     return self::$defaultAnnotationReader;
 }