/** * @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); }
protected function loadDriver() { $cache = new \Doctrine\Common\Cache\ArrayCache(); $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader(); $reader->addNamespace('Doctrine\\ODM\\CouchDB\\Mapping\\Annotations'); return new \Doctrine\ODM\CouchDB\Mapping\Driver\AnnotationDriver($reader); }
public function testIssueSimpleAnnotationReader() { $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader(); $reader->addNamespace('Doctrine\\Tests\\Common\\Annotations\\Ticket\\Doctrine\\ORM\\Mapping'); $annots = $reader->getClassAnnotations(new \ReflectionClass(__NAMESPACE__ . "\\MappedClass")); $this->assertEquals(1, count($annots)); $this->assertInstanceOf("Doctrine\\Tests\\Common\\Annotations\\Ticket\\Doctrine\\ORM\\Mapping\\Entity", $annots[0]); }
/** * @param array $paths * @param mixed $alias * @return AnnotationDriver */ protected function createAnnotationDriver($paths = array(), $alias = null) { if (version_compare(Version::VERSION, '3.0.0', '>=')) { $reader = new CachedReader(new AnnotationReader(), new ArrayCache()); } else { // if (version_compare(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()); } AnnotationRegistry::registerFile(__DIR__ . "/../../../lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php"); return new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, (array) $paths); }
public function createDocumentManager() { $couchDBClient = $this->createCouchDBClient(); $httpClient = $couchDBClient->getHttpClient(); $database = $couchDBClient->getDatabase(); $httpClient->request('DELETE', '/' . $database); $resp = $httpClient->request('PUT', '/' . $database); $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader(); $reader->addNamespace('Doctrine\\ODM\\CouchDB\\Mapping\\Annotations'); $paths = __DIR__ . "/../../Models"; $metaDriver = new AnnotationDriver($reader, $paths); $config = $this->createConfiguration($metaDriver); return DocumentManager::create($couchDBClient, $config); }
public function createDocumentManager() { $couchDBClient = $this->createCouchDBClient(); $httpClient = $couchDBClient->getHttpClient(); $database = $couchDBClient->getDatabase(); $httpClient->request('DELETE', '/' . $database); $resp = $httpClient->request('PUT', '/' . $database); $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader(); $reader->addNamespace('Doctrine\\ODM\\CouchDB\\Mapping\\Annotations'); $paths = __DIR__ . "/../../Models"; $metaDriver = new AnnotationDriver($reader, $paths); $config = new Configuration(); $config->setProxyDir(\sys_get_temp_dir()); $config->setAutoGenerateProxyClasses(true); $config->setMetadataDriverImpl($metaDriver); $setMetadataCacheImpl = $config->setMetadataCacheImpl(new ArrayCache()); $config->setLuceneHandlerName('_fti'); return DocumentManager::create($couchDBClient, $config); }
/** * Gibt einen neuen SimpleAnnotationReader zurück * * der Namespace Doctrine\ORM\Mapping wird automatisch hinzugefügt * es wird der interne Cache benutzt * @return Doctrine\Common\Annotations\SimpleAnnotationReader() */ public function createAnnotationReader($simple = TRUE, array $ignoredAnnotations = array()) { if ($simple) { $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader(); $reader->addNamespace('Doctrine\\ORM\\Mapping'); } else { $reader = new \Doctrine\Common\Annotations\AnnotationReader(); } foreach ($ignoredAnnotations as $ignore) { $reader->addGlobalIgnoredName($ignore); } $reader = new \Doctrine\Common\Annotations\CachedReader($reader, $this->getCache()); return $reader; }
/** * Add a new default annotation driver with a correctly configured annotation reader. * * @param array $paths * @return Mapping\Driver\AnnotationDriver */ public function newDefaultAnnotationDriver($paths = array()) { switch (true) { case version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>='): // Register the ORM Annotations in the AnnotationRegistry AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php'); $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader(); $reader->addNamespace('Doctrine\\ORM\\Mapping'); $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new ArrayCache()); break; case version_compare(\Doctrine\Common\Version::VERSION, '2.1.0-DEV', '>='): // Register the ORM Annotations in the AnnotationRegistry AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php'); $reader = new AnnotationReader(); $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\'); $reader->setIgnoreNotImportedAnnotations(true); $reader->setEnableParsePhpImports(false); $reader = new \Doctrine\Common\Annotations\CachedReader(new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache()); break; default: $reader = new AnnotationReader(); $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\'); break; } return new AnnotationDriver($reader, (array) $paths); }
/** * 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\SimpleAnnotationReader(); $reader->addNamespace('Doctrine\\ODM\\CouchDB\\Mapping\\Annotations'); return new \Doctrine\ODM\CouchDB\Mapping\Driver\AnnotationDriver($reader, (array) $paths); }
protected function createAnnotationDriver($paths = null, $alias = null) { // Register the ORM Annotations in the AnnotationRegistry $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader(); $reader->addNamespace('Doctrine\\ODM\\OrientDB\\Mapping\\Annotations'); $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new ArrayCache()); \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(__DIR__ . '/../../src/Doctrine/ODM/OrientDB/Mapping/Annotations/DoctrineAnnotations.php'); return new Mapping\Driver\AnnotationDriver($reader, (array) $paths); }
* Below that section you can place your test code and experiment. */ use Zend\ServiceManager\ServiceManager, Zend\Mvc\Service\ServiceManagerConfiguration; use Doctrine\ORM\Configuration, Doctrine\ORM\EntityManager, Doctrine\ORM\Mapping\Driver\DriverChain, Doctrine\Common\Annotations\AnnotationReader, Doctrine\Common\Annotations\AnnotationRegistry, Doctrine\ORM\Mapping\Driver\AnnotationDriver, Doctrine\ORM\Mapping\Driver\XmlDriver, Doctrine\ORM\Mapping\Driver\YamlDriver, Doctrine\Common\Cache\ArrayCache, Doctrine\Common\Cache\ApcCache; chdir(__DIR__ . '/..'); require_once 'vendor/autoload.php'; //Zend autoloader require_once 'Zend/Loader/AutoloaderFactory.php'; Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true))); // Get application stack configuration $configuration = (include 'config/application.config.php'); //Register for annotation driver $annotationReflection = new ReflectionClass('Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver'); $annotationsFile = realpath(dirname($annotationReflection->getFileName()) . '/DoctrineAnnotations.php'); AnnotationRegistry::registerFile($annotationsFile); $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader(); $reader->addNamespace('Doctrine\\ORM\\Mapping'); $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new ArrayCache()); /***/ // Setup service manager $serviceManager = new ServiceManager(new ServiceManagerConfiguration($configuration['service_manager'])); $serviceManager->setService('ApplicationConfiguration', $configuration); $modules = $serviceManager->get('ModuleManager')->loadModules(); $conf = $modules->getEvent()->getConfigListener()->getMergedConfig(); $drivers = $conf->di->instance->orm_driver_chain->parameters->drivers->toArray(); $driverChain = new DriverChain(); foreach ($drivers as $driver) { if (!is_array($driver)) { continue; } $class = $driver['class'];
/** * Create default annotation reader for extensions * * @return \Doctrine\Common\Annotations\AnnotationReader */ private function getDefaultAnnotationReader() { if (null === $this->defaultAnnotationReader) { if (version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>=')) { $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader(); $reader->addNamespace('Doctrine\\ORM\\Mapping'); \Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('Gedmo\\Mapping\\Annotation', __DIR__ . '/../../'); $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new ArrayCache()); } else { if (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()); } else { if (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); /*\Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace( 'Gedmo\\Mapping\\Annotation', __DIR__ . '/../../' );*/ $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\\'); } } } $this->defaultAnnotationReader = $reader; } return $this->defaultAnnotationReader; }