Example #1
0
 /**
  * @param array $paths
  * @return \Doctrine\Common\Annotations\AnnotationReader
  */
 protected function createAnnotationDriver($paths = array(), $alias = null)
 {
     if (version_compare(\Doctrine\Common\Version::VERSION, '3.0.0', '>=')) {
         $reader = new \Doctrine\Common\Annotations\CachedReader(new \Doctrine\Common\Annotations\AnnotationReader(), new ArrayCache());
     } else {
         if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0-BETA3-DEV', '>=')) {
             $reader = new \Doctrine\Common\Annotations\AnnotationReader();
             $reader->setIgnoreNotImportedAnnotations(true);
             $reader->setEnableParsePhpImports(false);
             if ($alias) {
                 $reader->setAnnotationNamespaceAlias('Doctrine\\ORM\\Mapping\\', $alias);
             } else {
                 $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
             }
             $reader = new \Doctrine\Common\Annotations\CachedReader(new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache());
         } else {
             $reader = new \Doctrine\Common\Annotations\AnnotationReader();
             if ($alias) {
                 $reader->setAnnotationNamespaceAlias('Doctrine\\ORM\\Mapping\\', $alias);
             } else {
                 $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
             }
         }
     }
     return new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, (array) $paths);
 }
Example #2
0
 public function __construct()
 {
     // load database configuration from CodeIgniter
     require_once APPPATH . 'config/database.php';
     // Set up class loading. You could use different autoloaders, provided by your favorite framework,
     // if you want to.
     require_once APPPATH . 'libraries/Doctrine/Common/ClassLoader.php';
     $doctrineClassLoader = new ClassLoader('Doctrine', APPPATH . 'libraries');
     $doctrineClassLoader->register();
     $entitiesClassLoader = new ClassLoader('models', rtrim(APPPATH, '/'));
     $entitiesClassLoader->register();
     $proxiesClassLoader = new ClassLoader('Proxies', APPPATH . 'models/proxies');
     $proxiesClassLoader->register();
     // Set up caches
     $config = new Configuration();
     $cache = new ArrayCache();
     $config->setMetadataCacheImpl($cache);
     $config->setQueryCacheImpl($cache);
     // Set up driver
     $Doctrine_AnnotationReader = new \Doctrine\Common\Annotations\AnnotationReader($cache);
     $Doctrine_AnnotationReader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
     $driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($Doctrine_AnnotationReader, APPPATH . 'models');
     $config->setMetadataDriverImpl($driver);
     // Proxy configuration
     $config->setProxyDir(APPPATH . '/models/proxies');
     $config->setProxyNamespace('Proxies');
     // Set up logger
     //$logger = new EchoSqlLogger;
     //$config->setSqlLogger($logger);
     $config->setAutoGenerateProxyClasses(TRUE);
     // Database connection information
     $connectionOptions = array('driver' => 'pdo_mysql', 'user' => $db['default']['username'], 'password' => $db['default']['password'], 'host' => $db['default']['hostname'], 'dbname' => $db['default']['database']);
     // Create EntityManager
     $this->em = EntityManager::create($connectionOptions, $config);
 }
 protected function _loadDriver()
 {
     $cache = new \Doctrine\Common\Cache\ArrayCache();
     $reader = new \Doctrine\Common\Annotations\AnnotationReader($cache);
     $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
     return new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader);
 }
Example #4
0
 /**
  * @param array $paths
  * @return \Doctrine\ORM\Mapping\Driver\AnnotationDriver
  */
 protected function createAnnotationDriver($paths = array(), $alias = null)
 {
     if (version_compare(\Doctrine\Common\Version::VERSION, '3.0.0', '>=')) {
         $reader = new \Doctrine\Common\Annotations\CachedReader(new \Doctrine\Common\Annotations\AnnotationReader(), new ArrayCache());
     } else {
         if (version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>=')) {
             // Register the ORM Annotations in the AnnotationRegistry
             $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader();
             $reader->addNamespace('Doctrine\\ORM\\Mapping');
             $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new ArrayCache());
         } else {
             if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0-BETA3-DEV', '>=')) {
                 $reader = new \Doctrine\Common\Annotations\AnnotationReader();
                 $reader->setIgnoreNotImportedAnnotations(true);
                 $reader->setEnableParsePhpImports(false);
                 if ($alias) {
                     $reader->setAnnotationNamespaceAlias('Doctrine\\ORM\\Mapping\\', $alias);
                 } else {
                     $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
                 }
                 $reader = new \Doctrine\Common\Annotations\CachedReader(new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache());
             } else {
                 $reader = new \Doctrine\Common\Annotations\AnnotationReader();
                 if ($alias) {
                     $reader->setAnnotationNamespaceAlias('Doctrine\\ORM\\Mapping\\', $alias);
                 } else {
                     $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
                 }
             }
         }
     }
     \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(__DIR__ . "/../../../lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php");
     return new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, (array) $paths);
 }
Example #5
0
 /**
  * @group DDC-706
  */
 public function testIsTransient()
 {
     $reader = new \Doctrine\Common\Annotations\AnnotationReader(new \Doctrine\Common\Cache\ArrayCache());
     $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
     $chain = new DriverChain();
     $chain->addDriver(new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, array()), 'Doctrine\\Tests\\Models\\CMS');
     $this->assertTrue($chain->isTransient('stdClass'), "stdClass isTransient");
     $this->assertFalse($chain->isTransient('Doctrine\\Tests\\Models\\CMS\\CmsUser'), "CmsUser is not Transient");
 }
 public function initialize($parameters = array())
 {
     parent::initialize($parameters);
     $schema = $this->getParameter('schema');
     $connectionName = $this->getParameter('name');
     $connectionOptions = $this->getParameter('options');
     $plugins = (array) $this->getParameter('plugins');
     $config = new \Doctrine\ORM\Configuration();
     $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $configuration = sfProjectConfiguration::getActive();
     $paths = array();
     if ($schema) {
         $paths[] = $schema;
     }
     $paths[] = realpath(__DIR__ . '/../config/doctrine');
     $paths[] = realpath(sfConfig::get('sf_config_dir') . '/doctrine');
     $enabledPlugins = $configuration->getPlugins();
     foreach ($configuration->getAllPluginPaths() as $plugin => $path) {
         if (!in_array($plugin, $enabledPlugins) || !in_array($plugin, $plugins)) {
             continue;
         }
         $paths[] = $path . '/config/doctrine';
     }
     $paths = array_unique($paths);
     $config->setMetadataDriverImpl(new YamlDriver($paths));
     $config->setProxyDir(sfConfig::get('sf_lib_dir') . '/Proxies');
     $config->setProxyNamespace('Proxies');
     $configuration = sfProjectConfiguration::getActive();
     if (sfConfig::get('sf_debug')) {
         $config->setSqlLogger(new sfDoctrineSqlLogger($configuration->getEventDispatcher()));
     }
     $method = sprintf('configureDoctrineConnection%s', $connectionName);
     $methodExists = method_exists($configuration, $method);
     if (method_exists($configuration, 'configureDoctrineConnection') && !$methodExists) {
         $configuration->configureDoctrineConnection($config);
     } else {
         if ($methodExists) {
             $configuration->{$method}($config);
         }
     }
     $this->em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
     if (method_exists($configuration, 'configureEntityManager')) {
         $configuration->configureEntityManager($this->em);
     }
     ActiveEntity::setEntityManager($this->em);
     // ODM MongoDB
     $config = new Doctrine\ODM\MongoDB\Configuration();
     $config->setProxyDir(sfConfig::get('sf_lib_dir') . '/Proxies');
     $config->setProxyNamespace('Proxies');
     $reader = new Doctrine\Common\Annotations\AnnotationReader();
     $reader->setDefaultAnnotationNamespace('Doctrine\\ODM\\MongoDB\\Mapping\\');
     $config->setMetadataDriverImpl(new Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver($reader, sfConfig::get('sf_lib_dir') . DIRECTORY_SEPARATOR . 'Documents'));
     $this->dm = Doctrine\ODM\MongoDB\DocumentManager::create(new \Doctrine\ODM\MongoDB\Mongo(), $config);
 }
Example #7
0
 /**
  * EntityManager mock object together with
  * annotation mapping driver and pdo_sqlite
  * database in memory
  *
  * @return EntityManager
  */
 protected function getMockSqliteEntityManager()
 {
     $conn = array('driver' => 'pdo_sqlite', 'memory' => true);
     $config = $this->getMock('Doctrine\\ORM\\Configuration');
     $config->expects($this->once())->method('getProxyDir')->will($this->returnValue(sys_get_temp_dir()));
     $config->expects($this->once())->method('getProxyNamespace')->will($this->returnValue('Proxy'));
     $config->expects($this->once())->method('getAutoGenerateProxyClasses')->will($this->returnValue(true));
     $reader = new \Doctrine\Common\Annotations\AnnotationReader();
     $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
     $mappingDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader);
     $config->expects($this->any())->method('getMetadataDriverImpl')->will($this->returnValue($mappingDriver));
     $em = EntityManager::create($conn, $config);
     return $em;
 }
 public function testHasGetMetadata_NamespaceSeperatorIsNotNormalized()
 {
     require_once __DIR__ . "/../../Models/Global/GlobalNamespaceModel.php";
     $reader = new \Doctrine\Common\Annotations\AnnotationReader(new \Doctrine\Common\Cache\ArrayCache());
     $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
     $metadataDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader);
     $metadataDriver->addPaths(array(__DIR__ . '/../../Models/Global/'));
     $entityManager = $this->_createEntityManager($metadataDriver);
     $mf = $entityManager->getMetadataFactory();
     $m1 = $mf->getMetadataFor("DoctrineGlobal_Article");
     $h1 = $mf->hasMetadataFor("DoctrineGlobal_Article");
     $h2 = $mf->hasMetadataFor("\\DoctrineGlobal_Article");
     $m2 = $mf->getMetadataFor("\\DoctrineGlobal_Article");
     $this->assertNotSame($m1, $m2);
     $this->assertFalse($h2);
     $this->assertTrue($h1);
 }
Example #9
0
 public function describeClass($class)
 {
     $return_array = null;
     if (self::$_cache_directory) {
         $filename = self::getCacheDirectory() . str_replace("\\", '_', $class) . '_description.cache.php';
         if (file_exists($filename)) {
             $return_array = unserialize(file_get_contents($filename));
         }
     }
     if ($return_array === null) {
         $reflection_class = new \ReflectionClass($class);
         $reader = new \Doctrine\Common\Annotations\AnnotationReader(new \Doctrine\Common\Cache\ArrayCache());
         $reader->setEnableParsePhpImports(true);
         $reader->setDefaultAnnotationNamespace('RedpillLinpro\\GamineBundle\\Annotations\\');
         $return_array = array();
         foreach ($reflection_class->getProperties() as $property) {
             $is_id = false;
             $annotations = $reader->getPropertyAnnotations($property);
             foreach ($annotations as $annotation) {
                 if (!method_exists($annotation, 'getKey')) {
                     continue;
                 }
                 switch ($annotation->getKey()) {
                     case 'id':
                         $return_array['primary_key']['property'] = $property->name;
                         $return_array['primary_key']['key'] = $property->name;
                         $is_id = true;
                         break;
                 }
                 $return_array['properties'][$property->name][$annotation->getKey()] = (array) $annotation;
             }
             if ($is_id && isset($return_array['properties'][$property->name]['column']['name'])) {
                 $return_array['primary_key']['key'] = $return_array['properties'][$property->name]['column']['name'];
             }
         }
         if (self::$_cache_directory) {
             file_put_contents($filename, serialize($return_array));
         }
     }
     return $return_array;
 }
Example #10
0
    } 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
$ormConfig->setAutoGenerateProxyClasses(true);
Example #11
0
 /**
  * Get an instance of a mapping driver
  *
  * @param string $type   The type of mapping driver (yaml, xml, annotation, etc.)
  * @param string $source The source for the driver
  * @return AbstractDriver $driver
  */
 private function _getMappingDriver($type, $source = null)
 {
     if ($source instanceof \Doctrine\ORM\Mapping\Driver\Driver) {
         return $source;
     }
     if (!isset(self::$_mappingDrivers[$type])) {
         return false;
     }
     $class = self::$_mappingDrivers[$type];
     if (is_subclass_of($class, 'Doctrine\\ORM\\Mapping\\Driver\\AbstractFileDriver')) {
         if (is_null($source)) {
             throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath();
         }
         $driver = new $class($source);
     } else {
         if ($class == 'Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver') {
             $reader = new \Doctrine\Common\Annotations\AnnotationReader(new \Doctrine\Common\Cache\ArrayCache());
             $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
             $driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, $source);
         } else {
             $driver = new $class($source);
         }
     }
     return $driver;
 }
Example #12
0
 /**
  * Add a new default annotation driver with a correctly configured annotation reader.
  * 
  * @param array $paths
  * @return Mapping\Driver\AnnotationDriver
  */
 public function newDefaultAnnotationDriver($paths = array())
 {
     $reader = new \Doctrine\Common\Annotations\AnnotationReader();
     $reader->setDefaultAnnotationNamespace('Doctrine\\ODM\\MongoDB\\Mapping\\');
     return new \Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver($reader, (array) $paths);
 }
Example #13
0
 
$doctrineClassLoader = new ClassLoader('Doctrine',  __DIR__.'libraries');
$doctrineClassLoader->register();
$entitiesClassLoader = new ClassLoader('models', __DIR__);
$entitiesClassLoader->register();
$proxiesClassLoader = new ClassLoader('Proxies', __DIR__.'models/proxies');
$proxiesClassLoader->register();
$config = new \Doctrine\ORM\Configuration();
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
$config->setProxyDir(__DIR__ . '/Proxies');
$config->setProxyNamespace('Proxies');
 
$cache = new ArrayCache;
// Set up driver
$Doctrine_AnnotationReader = new \Doctrine\Common\Annotations\AnnotationReader($cache);
$Doctrine_AnnotationReader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
$driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($Doctrine_AnnotationReader, realpath('../models'));
$config->setMetadataDriverImpl($driver);
 
// Database connection information
$connectionOptions = array(
    'driver' => 'pdo_mysql',
    'user' =>     $db['default']['username'],
    'password' => $db['default']['password'],
    'host' =>     $db['default']['hostname'],
    'dbname' =>   $db['default']['database']
);
 
$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
 
$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
Example #14
0
 /**
  * Gets the cache driver implementation that is used for the mapping metadata.
  *
  * @return object
  */
 public function getMetadataDriverImpl()
 {
     if ($this->_attributes['metadataDriverImpl'] == null) {
         $reader = new \Doctrine\Common\Annotations\AnnotationReader(new \Doctrine\Common\Cache\ArrayCache());
         $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
         $this->_attributes['metadataDriverImpl'] = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader);
     }
     return $this->_attributes['metadataDriverImpl'];
 }
 /**
  * Setup the metadata driver if necessary options are set. Otherwise Doctrine defaults are used (AnnotationReader).
  *
  * @param array $options
  * @param Doctrine\ORM\Configuration $config
  * @param Doctrine\Common\Cache\AbstractCache $cache
  * @param Doctrine\DBAL\Connection $conn
  */
 protected function _setupMetadataDriver($options, $config, $cache, $conn)
 {
     $driver = false;
     if (isset($options['metadata'])) {
         if (isset($options['metadata']['driver'])) {
             $driverName = $options['metadata']['driver'];
             switch (strtolower($driverName)) {
                 case 'annotation':
                     $driverName = 'Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver';
                     break;
                 case 'yaml':
                     $driverName = 'Doctrine\\ORM\\Mapping\\Driver\\YamlDriver';
                     break;
                 case 'xml':
                     $driverName = 'Doctrine\\ORM\\Mapping\\Driver\\XmlDriver';
                     break;
                 case 'php':
                     $driverName = 'Doctrine\\ORM\\Mapping\\Driver\\PhpDriver';
                     break;
                 case 'database':
                     $driverName = 'Doctrine\\ORM\\Mapping\\Driver\\DatabaseDriver';
                     break;
             }
             if (!class_exists($driverName)) {
                 throw new ZendX_Doctrine2_Exception("MetadataDriver class '" . $driverName . "' does not exist");
             }
             if (in_array('Doctrine\\ORM\\Mapping\\Driver\\AbstractFileDriver', class_parents($driverName))) {
                 if (!isset($options['metadata']['paths'])) {
                     throw new ZendX_Doctrine2_Exception("Metadata Driver is file based, but no config file paths were given.");
                 }
                 if (!isset($options['metadata']['mode'])) {
                     $options['metadata']['mode'] = \Doctrine\ORM\Mapping\Driver\AbstractFileDriver::FILE_PER_CLASS;
                 }
                 $driver = new $driverName($options['metadata']['paths'], $options['metadata']['mode']);
             } elseif ($driverName == 'Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver') {
                 $reader = new \Doctrine\Common\Annotations\AnnotationReader($cache);
                 $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
                 $driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader);
                 if (isset($options['metadata']['classDirectory'])) {
                     $driver->addPaths(array($options['metadata']['classDirectory']));
                 } else {
                     throw new ZendX_Doctrine2_Exception("Doctrine Annotation Driver requires to set a class directory for the entities.");
                 }
                 //$driverImpl = $config->newDefaultAnnotationDriver("var/www/zfbench/application/models"));
                 //$config->setMetadataDriverImpl($driverImpl);
             } elseif ($driverName == 'Doctrine\\ORM\\Mapping\\Driver\\DatabaseDriver') {
                 $schemaManager = $conn->getSchemaManager();
                 $driver = new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($schemaManager);
             }
             if (!$driver instanceof \Doctrine\ORM\Mapping\Driver\Driver) {
                 throw new ZendX_Doctrine2_Exception("No metadata driver could be loaded.");
             }
             $config->setMetadataDriverImpl($driver);
         }
     }
 }
    public function testLoadMetadata()
    {
        $metadata = $this->generateBookDocumentFixture();

        $book = $this->newInstance($metadata);

        $cm = new \Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo($metadata->name);
        $reader = new \Doctrine\Common\Annotations\AnnotationReader();
        $reader->setDefaultAnnotationNamespace("Doctrine\\ODM\\MongoDB\\Mapping\\");
        $driver = new \Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver($reader);
        $driver->loadMetadataForClass($cm->name, $cm);

        $this->assertEquals($cm->getCollection(), $metadata->getCollection());
        $this->assertEquals($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks);
        $this->assertEquals($cm->identifier, $metadata->identifier);
        $this->assertEquals($cm->idGenerator, $metadata->idGenerator);
        $this->assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName);
    }
 /**
  * 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;
 }
Example #18
0
	/**
	 * @param \Nette\DI\Container
	 * @return Mapping\Driver\AnnotationDriver
	 */
	public static function createServiceAnnotationDriver(DI\Container $context)
	{
		$reader = new \Doctrine\Common\Annotations\AnnotationReader();
		$reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');

		return new Mapping\Driver\AnnotationDriver($reader, $this->configuration['entityDirs']);
	}
 protected function getDoctrine_Odm_Mongodb_Metadata_AnnotationReaderService()
 {
     if (isset($this->shared['doctrine.odm.mongodb.metadata.annotation_reader'])) {
         return $this->shared['doctrine.odm.mongodb.metadata.annotation_reader'];
     }
     $instance = new Doctrine\Common\Annotations\AnnotationReader($this->getDoctrine_Odm_Mongodb_Cache_ArrayService());
     $this->shared['doctrine.odm.mongodb.metadata.annotation_reader'] = $instance;
     $instance->setDefaultAnnotationNamespace($this->getParameter('doctrine.odm.mongodb.metadata.annotation_default_namespace'));
     return $instance;
 }
 /**
  * Get an instance of a mapping driver
  *
  * @param string $type   The type of mapping driver (yaml, xml, annotation, etc.)
  * @param string $source The source for the driver
  * @return AbstractDriver $driver
  */
 public function getMappingDriver($type, $source = null)
 {
     if (!isset($this->_mappingDrivers[$type])) {
         return false;
     }
     $class = $this->_mappingDrivers[$type];
     if (is_subclass_of($class, 'Doctrine\\ORM\\Mapping\\Driver\\AbstractFileDriver')) {
         if (is_null($source)) {
             throw DoctrineException::fileMappingDriversRequireDirectoryPath();
         }
         $driver = new $class($source);
     } else {
         if ($class == 'Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver') {
             $reader = new \Doctrine\Common\Annotations\AnnotationReader(new \Doctrine\Common\Cache\ArrayCache());
             $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
             $driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, $source);
         } else {
             $driver = new $class($source);
         }
     }
     return $driver;
 }