private function setRelationships(ClassMetadataInfo $metadata, Metadata\EntityMetadata $entity)
    {
        $allTypes = $this->getAllTypeNames();
        foreach ($metadata->fieldMappings as $fieldKey => $mapping) {
            if (!isset($mapping['reference'])) {
                // Not a relationship. Skip.
                continue;
            }
            if (!isset($mapping['targetDocument'])) {
                // No target found. Skip.
                // @todo Should this throw an Exception?
                continue;
            }

            $type = $this->getTypeForClassName($mapping['targetDocument']);
            if (!in_array($type, $allTypes)) {
                throw new RuntimeException(sprintf('No metadata was found for related entity type "%s" as found on relationship field "%s::%s"', $type, $entity->type, $fieldKey));
            }

            $relationship = new Metadata\RelationshipMetadata($fieldKey, $mapping['type'], $type);
            if (isset($mapping['isInverseSide']) && true === $mapping['isInverseSide']) {
                $relationship->isInverse = true;
            }
            $entity->addRelationship($relationship);
        }
        return $entity;
    }
private function setRelationships(ClassMetadataInfo $metadata, Metadata\EntityMetadata $entity)
    {
        $allTypes = $this->getAllTypeNames();
        foreach ($metadata->fieldMappings as $fieldKey => $mapping) {
            if (!isset($mapping['reference'])) {
                // Not a relationship. Skip.
                continue;
            }
            if (!isset($mapping['targetDocument'])) {
                // No target found. Skip.
                // @todo Should this throw an Exception?
                continue;
            }

            $type = $this->getTypeForClassName($mapping['targetDocument']);
            if (!in_array($type, $allTypes)) {
                throw new RuntimeException(sprintf('No metadata was found for related entity type "%s" as found on relationship field "%s::%s"', $type, $entity->type, $fieldKey));
            }

            $relationship = new Metadata\RelationshipMetadata($fieldKey, $mapping['type'], $type);
            if (isset($mapping['isInverseSide']) && true === $mapping['isInverseSide']) {
                $relationship->isInverse = true;
            }
            $entity->addRelationship($relationship);
        }
        return $entity;
    }
private function setRelationships ( ClassMetadataInfo $ metadata , Metadata \ EntityMetadata $ entity ) { $ allTypes = $ this -> getAllTypeNames ( ) ; foreach ( $ metadata -> fieldMappings as $ fieldKey => $ mapping ) { if ( ! isset ( $ mapping [ 'reference' ] ) ) { // Not a relationship. Skip. continue ; } if ( ! isset ( $ mapping [ 'targetDocument' ] ) ) { // No target found. Skip. // @todo Should this throw an Exception? continue ; } $ type = $ this -> getTypeForClassName ( $ mapping [ 'targetDocument' ] ) ; if ( ! in_array ( $ type , $ allTypes ) ) { throw new RuntimeException ( sprintf ( 'No metadata was found for related entity type "%s" as found on relationship field "%s::%s"' , $ type , $ entity -> type , $ fieldKey ) ) ; } $ relationship = new Metadata \ RelationshipMetadata ( $ fieldKey , $ mapping [ 'type' ] , $ type ) ; if ( isset ( $ mapping [ 'isInverseSide' ] ) && true === $ mapping [ 'isInverseSide' ] ) { $ relationship -> isInverse = true ; } $ entity -> addRelationship ( $ relationship ) ; } return $ entity ; }
Sets the entity relationship metadata from the Doctrine class metadata.

@param   ClassMetadataInfo           $metadata
@param   Metadata\EntityMetadata     $entity
@return  Metadata\EntityMetadata
@throws  RuntimeException            If the Doctrine target document metadata was not found.
Sets the entity relationship metadata from the Doctrine class metadata .