Doctrine\ODM\CouchDB\DocumentManager::getClassMetadata PHP Method

getClassMetadata() public method

public getClassMetadata ( string $class ) : ClassMetadata
$class string
return Doctrine\ODM\CouchDB\Mapping\ClassMetadata
    public function getClassMetadata($class)
    {
        return $this->metadataFactory->getMetadataFor($class);
    }

Usage Example

 public function resolveJsonField(ClassMetadata $class, DocumentManager $dm, $documentState, $jsonName, $originalData)
 {
     $uow = $dm->getUnitOfWork();
     $couchClient = $dm->getCouchDBClient();
     if ($jsonName == 'doctrine_metadata' && isset($originalData['doctrine_metadata']['associations'])) {
         foreach ($originalData['doctrine_metadata']['associations'] as $assocName) {
             $assocValue = $originalData[$assocName];
             if (isset($class->associationsMappings[$assocName])) {
                 if ($class->associationsMappings[$assocName]['type'] & ClassMetadata::TO_ONE) {
                     if ($assocValue) {
                         if ($class->associationsMappings[$assocName]['targetDocument'] && !$dm->getClassMetadata($class->associationsMappings[$assocName]['targetDocument'])->inInheritanceHierachy) {
                             $assocValue = $dm->getReference($class->associationsMappings[$assocName]['targetDocument'], $assocValue);
                         } else {
                             $response = $couchClient->findDocument($assocValue);
                             if ($response->status == 404) {
                                 $assocValue = null;
                             } else {
                                 $hints = array();
                                 $assocValue = $uow->createDocument(null, $response->body, $hints);
                             }
                         }
                     }
                     $documentState[$class->associationsMappings[$assocName]['fieldName']] = $assocValue;
                 } else {
                     if ($class->associationsMappings[$assocName]['type'] & ClassMetadata::MANY_TO_MANY) {
                         if ($class->associationsMappings[$assocName]['isOwning']) {
                             $documentState[$class->associationsMappings[$assocName]['fieldName']] = new PersistentIdsCollection(new ArrayCollection(), $class->associationsMappings[$assocName]['targetDocument'], $dm, $assocValue);
                         }
                     }
                 }
             }
         }
     }
     return $documentState;
 }
All Usage Examples Of Doctrine\ODM\CouchDB\DocumentManager::getClassMetadata