当前位置: 首页>>代码示例>>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;未经允许,请勿转载。