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


PHP ClassMetadata::getReflectionProperties方法代碼示例

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


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

示例1: testClassMetadataInstanceSerialization

 public function testClassMetadataInstanceSerialization()
 {
     $cm = new ClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsUser');
     // Test initial state
     $this->assertTrue(count($cm->getReflectionProperties()) == 0);
     $this->assertTrue($cm->reflClass instanceof \ReflectionClass);
     $this->assertEquals('Doctrine\\Tests\\Models\\CMS\\CmsUser', $cm->name);
     $this->assertEquals('Doctrine\\Tests\\Models\\CMS\\CmsUser', $cm->rootEntityName);
     $this->assertEquals(array(), $cm->subClasses);
     $this->assertEquals(array(), $cm->parentClasses);
     // Customize state
     $cm->setSubclasses(array("One", "Two", "Three"));
     $cm->setParentClasses(array("UserParent"));
     $cm->setCustomRepositoryClass("UserRepository");
     $cm->setDiscriminatorColumn(array('name' => 'disc', 'type' => 'integer'));
     $cm->mapOneToOne(array('fieldName' => 'phonenumbers', 'targetEntity' => 'Bar', 'mappedBy' => 'foo'));
     $this->assertTrue($cm->getAssociationMapping('phonenumbers') instanceof \Doctrine\ORM\Mapping\OneToOneMapping);
     $this->assertEquals(1, count($cm->associationMappings));
     $serialized = serialize($cm);
     $cm = unserialize($serialized);
     // Check state
     $this->assertTrue(count($cm->getReflectionProperties()) > 0);
     $this->assertTrue($cm->reflClass instanceof \ReflectionClass);
     $this->assertEquals('Doctrine\\Tests\\Models\\CMS\\CmsUser', $cm->name);
     $this->assertEquals('UserParent', $cm->rootEntityName);
     $this->assertEquals(array('One', 'Two', 'Three'), $cm->subClasses);
     $this->assertEquals(array('UserParent'), $cm->parentClasses);
     $this->assertEquals('UserRepository', $cm->getCustomRepositoryClass());
     $this->assertEquals(array('name' => 'disc', 'type' => 'integer'), $cm->discriminatorColumn);
     $this->assertTrue($cm->getAssociationMapping('phonenumbers') instanceof \Doctrine\ORM\Mapping\OneToOneMapping);
     $this->assertEquals(1, count($cm->associationMappings));
     $oneOneMapping = $cm->getAssociationMapping('phonenumbers');
     $this->assertEquals('phonenumbers', $oneOneMapping->getSourceFieldName());
     $this->assertEquals('Doctrine\\Tests\\Models\\CMS\\Bar', $oneOneMapping->getTargetEntityName());
 }
開發者ID:jackbravo,項目名稱:doctrine,代碼行數:35,代碼來源:ClassMetadataTest.php

示例2: getResult

 public function getResult(ClassMetadata $classMetadata, array $options = [])
 {
     foreach ([true, false] as $strict) {
         foreach ($classMetadata->getReflectionProperties() as $reflProperty) {
             $property = $reflProperty->getName();
             if ($this->isTitlePropertyQuery->getResult($classMetadata, compact('property', 'strict'))) {
                 return $property;
             }
         }
     }
     return null;
 }
開發者ID:mikegibson,項目名稱:sentient,代碼行數:12,代碼來源:GetTitlePropertyQuery.php

示例3: testClassMetadataInstanceSerialization

    public function testClassMetadataInstanceSerialization()
    {
        $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');

        // Test initial state
        $this->assertTrue(count($cm->getReflectionProperties()) == 0);
        $this->assertInstanceOf('ReflectionClass', $cm->reflClass);
        $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->name);
        $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->rootEntityName);
        $this->assertEquals(array(), $cm->subClasses);
        $this->assertEquals(array(), $cm->parentClasses);
        $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $cm->inheritanceType);

        // Customize state
        $cm->setInheritanceType(ClassMetadata::INHERITANCE_TYPE_SINGLE_TABLE);
        $cm->setSubclasses(array("One", "Two", "Three"));
        $cm->setParentClasses(array("UserParent"));
        $cm->setCustomRepositoryClass("UserRepository");
        $cm->setDiscriminatorColumn(array('name' => 'disc', 'type' => 'integer'));
        $cm->mapOneToOne(array('fieldName' => 'phonenumbers', 'targetEntity' => 'Bar', 'mappedBy' => 'foo'));
        $cm->markReadOnly();
        $cm->addNamedQuery(array('name' => 'dql', 'query' => 'foo'));
        $this->assertEquals(1, count($cm->associationMappings));

        $serialized = serialize($cm);
        $cm = unserialize($serialized);

        // Check state
        $this->assertTrue(count($cm->getReflectionProperties()) > 0);
        $this->assertEquals('Doctrine\Tests\Models\CMS', $cm->namespace);
        $this->assertInstanceOf('ReflectionClass', $cm->reflClass);
        $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->name);
        $this->assertEquals('UserParent', $cm->rootEntityName);
        $this->assertEquals(array('Doctrine\Tests\Models\CMS\One', 'Doctrine\Tests\Models\CMS\Two', 'Doctrine\Tests\Models\CMS\Three'), $cm->subClasses);
        $this->assertEquals(array('UserParent'), $cm->parentClasses);
        $this->assertEquals('Doctrine\Tests\Models\CMS\UserRepository', $cm->customRepositoryClassName);
        $this->assertEquals(array('name' => 'disc', 'type' => 'integer', 'fieldName' => 'disc'), $cm->discriminatorColumn);
        $this->assertTrue($cm->associationMappings['phonenumbers']['type'] == ClassMetadata::ONE_TO_ONE);
        $this->assertEquals(1, count($cm->associationMappings));
        $oneOneMapping = $cm->getAssociationMapping('phonenumbers');
        $this->assertTrue($oneOneMapping['fetch'] == ClassMetadata::FETCH_LAZY);
        $this->assertEquals('phonenumbers', $oneOneMapping['fieldName']);
        $this->assertEquals('Doctrine\Tests\Models\CMS\Bar', $oneOneMapping['targetEntity']);
        $this->assertTrue($cm->isReadOnly);
        $this->assertEquals(array('dql' => 'foo'), $cm->namedQueries);
    }
開發者ID:naderman,項目名稱:doctrine2,代碼行數:46,代碼來源:ClassMetadataTest.php

示例4: _generateSleep

 /**
  * Generates the code for the __sleep method for a proxy class.
  *
  * @param $class
  * @return string
  */
 private function _generateSleep(ClassMetadata $class)
 {
     $sleepImpl = '';
     if ($class->reflClass->hasMethod('__sleep')) {
         $sleepImpl .= "return array_merge(array('__isInitialized__'), parent::__sleep());";
     } else {
         $sleepImpl .= "return array('__isInitialized__', ";
         $first = true;
         foreach ($class->getReflectionProperties() as $name => $prop) {
             if ($first) {
                 $first = false;
             } else {
                 $sleepImpl .= ', ';
             }
             $sleepImpl .= "'" . $name . "'";
         }
         $sleepImpl .= ');';
     }
     return $sleepImpl;
 }
開發者ID:laiello,項目名稱:masfletes,代碼行數:26,代碼來源:ProxyFactory.php

示例5: testWakeupReflectionWithEmbeddableAndStaticReflectionService

 public function testWakeupReflectionWithEmbeddableAndStaticReflectionService()
 {
     $classMetadata = new ClassMetadata('Doctrine\\Tests\\ORM\\Mapping\\TestEntity1');
     $classMetadata->mapEmbedded(array('fieldName' => 'test', 'class' => 'Doctrine\\Tests\\ORM\\Mapping\\TestEntity1', 'columnPrefix' => false));
     $field = array('fieldName' => 'test.embeddedProperty', 'type' => 'string', 'originalClass' => 'Doctrine\\Tests\\ORM\\Mapping\\TestEntity1', 'declaredField' => 'test', 'originalField' => 'embeddedProperty');
     $classMetadata->mapField($field);
     $classMetadata->wakeupReflection(new StaticReflectionService());
     $this->assertEquals(array('test' => null, 'test.embeddedProperty' => null), $classMetadata->getReflectionProperties());
 }
開發者ID:selimcr,項目名稱:servigases,代碼行數:9,代碼來源:ClassMetadataTest.php


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