當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ClassMetadata::initializeReflection方法代碼示例

本文整理匯總了PHP中Doctrine\ORM\Mapping\ClassMetadata::initializeReflection方法的典型用法代碼示例。如果您正苦於以下問題:PHP ClassMetadata::initializeReflection方法的具體用法?PHP ClassMetadata::initializeReflection怎麽用?PHP ClassMetadata::initializeReflection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\ORM\Mapping\ClassMetadata的用法示例。


在下文中一共展示了ClassMetadata::initializeReflection方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testClassMetadataValidation

 /**
  * @expectedException Prezent\Doctrine\Translatable\Mapping\MappingException
  */
 public function testClassMetadataValidation()
 {
     $classMetadata = new ClassMetadata('Prezent\\Tests\\Fixture\\BadMappingTranslation');
     $classMetadata->initializeReflection(new RuntimeReflectionService());
     $eventArgs = new LoadClassMetadataEventArgs($classMetadata, $this->getEntityManager());
     $this->getTranslatableListener()->loadClassMetadata($eventArgs);
 }
開發者ID:prezent,項目名稱:doctrine-translatable,代碼行數:10,代碼來源:TranslatableListenerValidationTest.php

示例2: testColumnWithMissingTypeDefaultsToString

 /**
  * @group DDC-268
  */
 public function testColumnWithMissingTypeDefaultsToString()
 {
     $cm = new ClassMetadata('Doctrine\\Tests\\ORM\\Mapping\\ColumnWithoutType');
     $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     $annotationDriver = $this->_loadDriver();
     $annotationDriver->loadMetadataForClass('Doctrine\\Tests\\ORM\\Mapping\\InvalidColumn', $cm);
     $this->assertEquals('string', $cm->fieldMappings['id']['type']);
 }
開發者ID:pnaq57,項目名稱:zf2demo,代碼行數:11,代碼來源:AnnotationDriverTest.php

示例3: testSkipAbstractClassesOnGeneration

 /**
  * @group DDC-1771
  */
 public function testSkipAbstractClassesOnGeneration()
 {
     $cm = new ClassMetadata(__NAMESPACE__ . '\\AbstractClass');
     $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     $this->assertNotNull($cm->reflClass);
     $num = $this->proxyFactory->generateProxyClasses(array($cm));
     $this->assertEquals(0, $num, "No proxies generated.");
 }
開發者ID:pnaq57,項目名稱:zf2demo,代碼行數:11,代碼來源:ProxyFactoryTest.php

示例4: createClassMetadata

 public function createClassMetadata($entityClassName)
 {
     $mappingDriver = $this->_loadDriver();
     $class = new ClassMetadata($entityClassName);
     $class->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     $mappingDriver->loadMetadataForClass($entityClassName, $class);
     return $class;
 }
開發者ID:r1pp3rj4ck,項目名稱:doctrine2,代碼行數:8,代碼來源:AbstractMappingDriverTest.php

示例5: testGetTableName

 public function testGetTableName()
 {
     $cm = $this->createClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsUser');
     $cm->setPrimaryTable(array('name' => '`cms_user`'));
     $this->assertEquals('"cms_user"', $this->strategy->getTableName($cm, $this->platform));
     $cm = new ClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsUser');
     $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     $cm->setPrimaryTable(array('name' => 'cms_user'));
     $this->assertEquals('cms_user', $this->strategy->getTableName($cm, $this->platform));
 }
開發者ID:Herriniaina,項目名稱:iVarotra,代碼行數:10,代碼來源:QuoteStrategyTest.php

示例6: testClassTableInheritanceDiscriminatorMap

 public function testClassTableInheritanceDiscriminatorMap()
 {
     $className = 'Doctrine\\Tests\\ORM\\Mapping\\CTI';
     $mappingDriver = $this->_loadDriver();
     $class = new ClassMetadata($className);
     $class->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     $mappingDriver->loadMetadataForClass($className, $class);
     $expectedMap = array('foo' => 'Doctrine\\Tests\\ORM\\Mapping\\CTIFoo', 'bar' => 'Doctrine\\Tests\\ORM\\Mapping\\CTIBar', 'baz' => 'Doctrine\\Tests\\ORM\\Mapping\\CTIBaz');
     $this->assertEquals(3, count($class->discriminatorMap));
     $this->assertEquals($expectedMap, $class->discriminatorMap);
 }
開發者ID:selimcr,項目名稱:servigases,代碼行數:11,代碼來源:XmlMappingDriverTest.php

示例7: createClassMetadata

 public function createClassMetadata(GClass $gClass)
 {
     // da wir gClass mehrmals im Test evalen könnten, erzeugen wir einen unique hash für den classname und übergeben den
     // der class metadata
     $className = uniqid($gClass->getClassName());
     $gClass->setClassName($className);
     $gClass->createDocBlock()->addAnnotation(Annotation::createDC('Entity'));
     $classWriter = new ClassWriter($gClass);
     $classWriter->setUseStyle('lines');
     $classWriter->addImport(new GClass('Doctrine\\ORM\\Mapping'), 'ORM');
     // braucht einen AnnotationReader nicht SimpleAnnotationReader
     $classWriter->write($file = $this->newFile('entity.' . $gClass->getClassName() . '.php'));
     require $file;
     $cm = new ClassMetadata($gClass->getFQN());
     $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     $this->annotationDriver->loadMetadataForClass($gClass->getFQN(), $cm);
     $file->delete();
     return $cm;
 }
開發者ID:pscheit,項目名稱:psc-cms,代碼行數:19,代碼來源:EntityRelationBaseTest.php

示例8: testGetMetadataForSingleClass

 public function testGetMetadataForSingleClass()
 {
     $mockDriver = new MetadataDriverMock();
     $entityManager = $this->_createEntityManager($mockDriver);
     $conn = $entityManager->getConnection();
     $mockPlatform = $conn->getDatabasePlatform();
     $mockPlatform->setPrefersSequences(true);
     $mockPlatform->setPrefersIdentityColumns(false);
     // Self-made metadata
     $cm1 = new ClassMetadata('Doctrine\\Tests\\ORM\\Mapping\\TestEntity1');
     $cm1->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     $cm1->setPrimaryTable(array('name' => '`group`'));
     // Add a mapped field
     $cm1->mapField(array('fieldName' => 'name', 'type' => 'varchar'));
     // Add a mapped field
     $cm1->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true));
     // and a mapped association
     $cm1->mapOneToOne(array('fieldName' => 'other', 'targetEntity' => 'TestEntity1', 'mappedBy' => 'this'));
     // and an association on the owning side
     $joinColumns = array(array('name' => 'other_id', 'referencedColumnName' => 'id'));
     $cm1->mapOneToOne(array('fieldName' => 'association', 'targetEntity' => 'TestEntity1', 'joinColumns' => $joinColumns));
     // and an id generator type
     $cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO);
     // SUT
     $cmf = new \Doctrine\ORM\Mapping\ClassMetadataFactory();
     $cmf->setEntityManager($entityManager);
     $cmf->setMetadataFor('Doctrine\\Tests\\ORM\\Mapping\\TestEntity1', $cm1);
     // Prechecks
     $this->assertEquals(array(), $cm1->parentClasses);
     $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $cm1->inheritanceType);
     $this->assertTrue($cm1->hasField('name'));
     $this->assertEquals(2, count($cm1->associationMappings));
     $this->assertEquals(ClassMetadata::GENERATOR_TYPE_AUTO, $cm1->generatorType);
     $this->assertEquals('group', $cm1->table['name']);
     // Go
     $cmMap1 = $cmf->getMetadataFor('Doctrine\\Tests\\ORM\\Mapping\\TestEntity1');
     $this->assertSame($cm1, $cmMap1);
     $this->assertEquals('group', $cmMap1->table['name']);
     $this->assertTrue($cmMap1->table['quoted']);
     $this->assertEquals(array(), $cmMap1->parentClasses);
     $this->assertTrue($cmMap1->hasField('name'));
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:42,代碼來源:ClassMetadataFactoryTest.php

示例9: testDoctrineProxy

 public function testDoctrineProxy()
 {
     $className = 'Saxulum\\Tests\\Accessor\\Fixtures\\Entity\\Entity';
     $proxyDirectory = __DIR__ . '/../proxy/';
     $proxyNamespace = 'Proxy';
     $proxyClassName = $proxyNamespace . '\\__CG__\\' . $className;
     $proxyClassFilename = $proxyDirectory . str_replace('\\', '_', $proxyClassName) . '.php';
     if (!is_dir($proxyDirectory)) {
         mkdir($proxyDirectory, 0777, true);
     }
     $reflectionService = new RuntimeReflectionService();
     $classMetadata = new ClassMetadata(get_class(new Entity()));
     $classMetadata->initializeReflection($reflectionService);
     $proxyGenerator = new ProxyGenerator($proxyDirectory, $proxyNamespace);
     $proxyGenerator->generateProxyClass($classMetadata, $proxyClassFilename);
     require $proxyClassFilename;
     /** @var Entity $proxy */
     $proxy = new $proxyClassName();
     $proxy->setName('test');
     $this->assertEquals('test', $proxy->getName());
     unlink($proxyClassFilename);
     //rmdir($proxyDirectory);
 }
開發者ID:saxulum,項目名稱:saxulum-accessor,代碼行數:23,代碼來源:DoctrineTest.php

示例10: testInvalidCascade

 /**
  * @group DDC-1746
  */
 public function testInvalidCascade()
 {
     $cm = new ClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsUser');
     $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     $this->setExpectedException("Doctrine\\ORM\\Mapping\\MappingException", "Invalid cascade option(s) specified: 'invalid'. Only 'remove', 'persist', 'refresh', 'merge' and 'detach' are allowed.");
     $cm->mapManyToOne(array('fieldName' => 'address', 'targetEntity' => 'UnknownClass', 'cascade' => array('invalid')));
 }
開發者ID:davidbui2,項目名稱:doctrine2,代碼行數:10,代碼來源:ClassMetadataTest.php

示例11: testTargetEntityNotFound

 /**
  * @group ImproveErrorMessages
  */
 public function testTargetEntityNotFound()
 {
     $cm = new ClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsUser');
     $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     $cm->mapManyToOne(array('fieldName' => 'address', 'targetEntity' => 'UnknownClass'));
     $this->setExpectedException("Doctrine\\ORM\\Mapping\\MappingException", "The target-entity Doctrine\\Tests\\Models\\CMS\\UnknownClass cannot be found in 'Doctrine\\Tests\\Models\\CMS\\CmsUser#address'.");
     $cm->validateAssocations();
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:11,代碼來源:ClassMetadataTest.php

示例12: getDirectlyAssociatedEntities

 /**
  * Returns the class names of additional entities that are directly associated with
  * one of the entities that is explicitly mentioned in the given configuration.
  *
  * @param Configuration $config
  * @param string[] $entityClasses Classes whose associations are checked.
  * @return string[] Associated entity classes.
  */
 protected function getDirectlyAssociatedEntities(Configuration $config, $entityClasses)
 {
     if (count($entityClasses) === 0) {
         return array();
     }
     $associatedEntities = array();
     foreach ($entityClasses as $entityClass) {
         /* @var $entityClass string */
         $metadata = new ClassMetadata($entityClass);
         $metadata->initializeReflection($this->reflectionService);
         $config->getMetadataDriverImpl()->loadMetadataForClass($entityClass, $metadata);
         foreach ($metadata->getAssociationNames() as $name) {
             /* @var $name string */
             $associatedEntity = $metadata->getAssociationTargetClass($name);
             $associatedEntities[] = $metadata->fullyQualifiedClassName($associatedEntity);
         }
         if (count($metadata->discriminatorMap) > 0) {
             $childClasses = array_values($metadata->discriminatorMap);
             $associatedEntities = array_merge($associatedEntities, $childClasses);
         }
         // Add parent classes that are involved in some kind of entity inheritance.
         foreach ($this->reflectionService->getParentClasses($entityClass) as $parentClass) {
             if (!$config->getMetadataDriverImpl()->isTransient($parentClass)) {
                 $associatedEntities[] = $parentClass;
             }
         }
     }
     return array_unique($associatedEntities);
 }
開發者ID:webfactory,項目名稱:doctrine-orm-test-infrastructure,代碼行數:37,代碼來源:EntityDependencyResolver.php

示例13: createClassMetadata

 /**
  * @param   string $className
  * @return \Doctrine\ORM\Mapping\ClassMetadata
  */
 private function createClassMetadata($className)
 {
     $class = new ClassMetadata($className);
     $class->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     return $class;
 }
開發者ID:selimcr,項目名稱:servigases,代碼行數:10,代碼來源:AnsiQuoteStrategyTest.php

示例14: setUp

 public function setUp()
 {
     $this->cm = new ClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsUser');
     $this->cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     $this->builder = new ClassMetadataBuilder($this->cm);
 }
開發者ID:Herriniaina,項目名稱:iVarotra,代碼行數:6,代碼來源:ClassMetadataBuilderTest.php

示例15: testCanInstantiateInternalPhpClassSubclass

 /**
  * @group DDC-3120
  */
 public function testCanInstantiateInternalPhpClassSubclass()
 {
     $classMetadata = new ClassMetadata(__NAMESPACE__ . '\\MyArrayObjectEntity');
     $classMetadata->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     $this->assertInstanceOf(__NAMESPACE__ . '\\MyArrayObjectEntity', $classMetadata->newInstance());
 }
開發者ID:annProg,項目名稱:yourCMDB,代碼行數:9,代碼來源:ClassMetadataTest.php


注:本文中的Doctrine\ORM\Mapping\ClassMetadata::initializeReflection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。