当前位置: 首页>>代码示例>>PHP>>正文


PHP AnnotationReader::setAutoloadAnnotations方法代码示例

本文整理汇总了PHP中Doctrine\Common\Annotations\AnnotationReader::setAutoloadAnnotations方法的典型用法代码示例。如果您正苦于以下问题:PHP AnnotationReader::setAutoloadAnnotations方法的具体用法?PHP AnnotationReader::setAutoloadAnnotations怎么用?PHP AnnotationReader::setAutoloadAnnotations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\Common\Annotations\AnnotationReader的用法示例。


在下文中一共展示了AnnotationReader::setAutoloadAnnotations方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 public function setUp()
 {
     if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0RC4-DEV', '>=')) {
         $this->markTestSkipped('Doctrine common is 2.1.0RC4-DEV version, skipping.');
     } else {
         if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0-BETA3-DEV', '>=')) {
             $reader = new AnnotationReader();
             $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
             $reader->setIgnoreNotImportedAnnotations(true);
             $reader->setAnnotationNamespaceAlias('Gedmo\\Mapping\\Annotation\\', 'gedmo');
             $reader->setEnableParsePhpImports(false);
             $reader->setAutoloadAnnotations(true);
             $reader = new CachedReader(new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache());
         } else {
             $reader = new AnnotationReader();
             $reader->setAutoloadAnnotations(true);
             $reader->setAnnotationNamespaceAlias('Gedmo\\Mapping\\Annotation\\', 'gedmo');
             $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
         }
     }
     $config = new \Doctrine\ORM\Configuration();
     $config->setProxyDir(TESTS_TEMP_DIR);
     $config->setProxyNamespace('Gedmo\\Mapping\\Proxy');
     $config->setMetadataDriverImpl(new AnnotationDriver($reader));
     $conn = array('driver' => 'pdo_sqlite', 'memory' => true);
     //$config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());
     $evm = new \Doctrine\Common\EventManager();
     $this->timestampable = new \Gedmo\Timestampable\TimestampableListener();
     $evm->addEventSubscriber($this->timestampable);
     $this->em = \Doctrine\ORM\EntityManager::create($conn, $config, $evm);
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
     $schemaTool->dropSchema(array());
     $schemaTool->createSchema(array($this->em->getClassMetadata(self::ARTICLE)));
 }
开发者ID:robertowest,项目名称:CuteFlow-V4,代码行数:34,代码来源:CompatibilityMappingTest.php

示例2: testAnnotations

 public function testAnnotations()
 {
     $reader = new AnnotationReader(new \Doctrine\Common\Cache\ArrayCache());
     $reader->setDefaultAnnotationNamespace('Doctrine\\Tests\\Common\\Annotations\\');
     $this->assertFalse($reader->getAutoloadAnnotations());
     $reader->setAutoloadAnnotations(true);
     $this->assertTrue($reader->getAutoloadAnnotations());
     $reader->setAutoloadAnnotations(false);
     $this->assertFalse($reader->getAutoloadAnnotations());
     $class = new ReflectionClass('Doctrine\\Tests\\Common\\Annotations\\DummyClass');
     $classAnnots = $reader->getClassAnnotations($class);
     $annotName = 'Doctrine\\Tests\\Common\\Annotations\\DummyAnnotation';
     $this->assertEquals(1, count($classAnnots));
     $this->assertTrue($classAnnots[$annotName] instanceof DummyAnnotation);
     $this->assertEquals("hello", $classAnnots[$annotName]->dummyValue);
     $field1Prop = $class->getProperty('field1');
     $propAnnots = $reader->getPropertyAnnotations($field1Prop);
     $this->assertEquals(1, count($propAnnots));
     $this->assertTrue($propAnnots[$annotName] instanceof DummyAnnotation);
     $this->assertEquals("fieldHello", $propAnnots[$annotName]->dummyValue);
     $getField1Method = $class->getMethod('getField1');
     $methodAnnots = $reader->getMethodAnnotations($getField1Method);
     $this->assertEquals(1, count($methodAnnots));
     $this->assertTrue($methodAnnots[$annotName] instanceof DummyAnnotation);
     $this->assertEquals(array(1, 2, "three"), $methodAnnots[$annotName]->value);
     $field2Prop = $class->getProperty('field2');
     $propAnnots = $reader->getPropertyAnnotations($field2Prop);
     $this->assertEquals(1, count($propAnnots));
     $this->assertTrue(isset($propAnnots['Doctrine\\Tests\\Common\\Annotations\\DummyJoinTable']));
     $joinTableAnnot = $propAnnots['Doctrine\\Tests\\Common\\Annotations\\DummyJoinTable'];
     $this->assertEquals(1, count($joinTableAnnot->joinColumns));
     $this->assertEquals(1, count($joinTableAnnot->inverseJoinColumns));
     $this->assertTrue($joinTableAnnot->joinColumns[0] instanceof DummyJoinColumn);
     $this->assertTrue($joinTableAnnot->inverseJoinColumns[0] instanceof DummyJoinColumn);
     $this->assertEquals('col1', $joinTableAnnot->joinColumns[0]->name);
     $this->assertEquals('col2', $joinTableAnnot->joinColumns[0]->referencedColumnName);
     $this->assertEquals('col3', $joinTableAnnot->inverseJoinColumns[0]->name);
     $this->assertEquals('col4', $joinTableAnnot->inverseJoinColumns[0]->referencedColumnName);
     $dummyAnnot = $reader->getMethodAnnotation($class->getMethod('getField1'), 'Doctrine\\Tests\\Common\\Annotations\\DummyAnnotation');
     $this->assertEquals('', $dummyAnnot->dummyValue);
     $this->assertEquals(array(1, 2, 'three'), $dummyAnnot->value);
     $dummyAnnot = $reader->getPropertyAnnotation($class->getProperty('field1'), 'Doctrine\\Tests\\Common\\Annotations\\DummyAnnotation');
     $this->assertEquals('fieldHello', $dummyAnnot->dummyValue);
     $classAnnot = $reader->getClassAnnotation($class, 'Doctrine\\Tests\\Common\\Annotations\\DummyAnnotation');
     $this->assertEquals('hello', $classAnnot->dummyValue);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:46,代码来源:AnnotationReaderTest.php

示例3: testLoadClassMetadataReturnsTrueIfSuccessful

 public function testLoadClassMetadataReturnsTrueIfSuccessful()
 {
     $reader = new AnnotationReader();
     $reader->setAutoloadAnnotations(true);
     $loader = new AnnotationLoader($reader);
     $metadata = new ClassMetadata('Symfony\\Tests\\Component\\Validator\\Fixtures\\Entity');
     $this->assertTrue($loader->loadClassMetadata($metadata));
 }
开发者ID:nightchiller,项目名称:symfony,代码行数:8,代码来源:AnnotationLoaderTest.php

示例4: getDefaultAnnotationReader

 /**
  * 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());
         } 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);
                     $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;
 }
开发者ID:pabloasc,项目名称:test_social,代码行数:39,代码来源:MappedEventSubscriber.php

示例5: __construct

 /**
  * Build the AnnotationLoader with an AnnotationReader
  *
  * @param AnnotationReader $reader
  */
 public function __construct(AnnotationReader $reader)
 {
     $this->reader = $reader;
     $this->reader->setAutoloadAnnotations(true);
     $this->reader->setAnnotationNamespaceAlias('Hitch\\Mapping\\Annotation\\', 'xml');
 }
开发者ID:kustov-vitalik,项目名称:xml-hitch,代码行数:11,代码来源:AnnotationLoader.php


注:本文中的Doctrine\Common\Annotations\AnnotationReader::setAutoloadAnnotations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。