/** * Return the class metadata instance * * @param string $entityName * * @return ClassMetaDataCollection */ public function getClassMetadata($entityName) { $r = new \ReflectionClass($entityName); $instanceMetadataCollection = new ClassMetaDataCollection(); $instanceMetadataCollection->name = $entityName; $classAnnotations = $this->reader->getClassAnnotations($r); foreach ($classAnnotations as $classAnnotation) { if ($classAnnotation instanceof RepositoryAttribute) { $instanceMetadataCollection->setRepository($classAnnotation->getValue()); } if ($classAnnotation instanceof ObjectClass) { $instanceMetadataCollection->setObjectClass($classAnnotation->getValue()); } } foreach ($r->getProperties() as $publicAttr) { $annotations = $this->reader->getPropertyAnnotations($publicAttr); foreach ($annotations as $annotation) { if ($annotation instanceof Attribute) { $varname = $publicAttr->getName(); $attribute = $annotation->getName(); $instanceMetadataCollection->addMeta($varname, $attribute); } if ($annotation instanceof DnLinkArray) { $varname = $publicAttr->getName(); $instanceMetadataCollection->addArrayOfLink($varname, $annotation->getValue()); } if ($annotation instanceof Sequence) { $varname = $publicAttr->getName(); $instanceMetadataCollection->addSequence($varname, $annotation->getValue()); } if ($annotation instanceof DnPregMatch) { $varname = $publicAttr->getName(); $instanceMetadataCollection->addRegex($varname, $annotation->getValue()); } if ($annotation instanceof ParentDn) { $varname = $publicAttr->getName(); $instanceMetadataCollection->addParentLink($varname, $annotation->getValue()); } if ($annotation instanceof ArrayField) { $instanceMetadataCollection->addArrayField($varname); } } } return $instanceMetadataCollection; }
/** * @covers Gorg\Bundle\LdapOrmBundle\Mapping\ClassMetaDataCollection::addSequence * @covers Gorg\Bundle\LdapOrmBundle\Mapping\ClassMetaDataCollection::isSequence * @covers Gorg\Bundle\LdapOrmBundle\Mapping\ClassMetaDataCollection::getSequence */ public function testAddSequence() { $this->object->addSequence('attributePHP', 'SequenceDn'); $this->assertTrue($this->object->isSequence('attributePHP')); $this->assertEquals($this->object->getSequence('attributePHP'), 'SequenceDn'); }