コード例 #1
0
ファイル: MetadataTest.php プロジェクト: tystr/redis-orm
 public function testGetMappingForMappedName()
 {
     $metadata = new Metadata();
     $mapping = array('name' => 'some_property', 'type' => 'string');
     $metadata->addPropertyMapping('someProperty', $mapping);
     $mapping['propertyName'] = 'someProperty';
     assertEquals($mapping, $metadata->getMappingForMappedName('some_property'));
 }
コード例 #2
0
 /**
  * @param AnnotationReader $reader
  * @param \ReflectionClass $reflClass
  */
 protected function loadPropertyAnnotations(AnnotationReader $reader, ReflectionClass $reflClass)
 {
     foreach ($reflClass->getProperties() as $property) {
         foreach ($reader->getPropertyAnnotations($property) as $annotation) {
             if ($annotation instanceof SortedIndex) {
                 $this->metadata->addSortedIndex($property->getName(), $this->getKeyNameFromAnnotation($property, $annotation));
             } elseif ($annotation instanceof Index) {
                 $this->metadata->addIndex($property->getName(), $this->getKeyNameFromAnnotation($property, $annotation));
             } elseif ($annotation instanceof Id) {
                 $this->metadata->setId($property->getName());
             } elseif ($annotation instanceof Field) {
                 $this->metadata->addPropertyMapping($property->getName(), array('type' => $annotation->type, 'name' => $annotation->name));
             }
         }
     }
 }