@@ 122-139 (lines=18) @@ | ||
119 | } |
|
120 | ||
121 | parent::connectFromField($referencedFieldName); |
|
122 | } else { |
|
123 | if (isset($referenceMapping['repositoryMethod'])) { |
|
124 | throw MappingException::repositoryMethodLookupNotAllowed($this->class->name, $connectFromField); |
|
125 | } |
|
126 | ||
127 | $mappedByMapping = $this->targetClass->getFieldMapping($referenceMapping['mappedBy']); |
|
128 | switch ($mappedByMapping['storeAs']) { |
|
129 | case ClassMetadataInfo::REFERENCE_STORE_AS_ID: |
|
130 | case ClassMetadataInfo::REFERENCE_STORE_AS_REF: |
|
131 | $referencedFieldName = ClassMetadataInfo::getReferenceFieldName($mappedByMapping['storeAs'], $mappedByMapping['name']); |
|
132 | break; |
|
133 | ||
134 | default: |
|
135 | throw MappingException::cannotLookupDbRefReference($this->class->name, $connectFromField); |
|
136 | } |
|
137 | ||
138 | parent::connectFromField($referencedFieldName); |
|
139 | } |
|
140 | ||
141 | return $this; |
|
142 | } |
@@ 126-145 (lines=20) @@ | ||
123 | $this |
|
124 | ->foreignField('_id') |
|
125 | ->localField($referencedFieldName); |
|
126 | } else { |
|
127 | if (isset($referenceMapping['repositoryMethod'])) { |
|
128 | throw MappingException::repositoryMethodLookupNotAllowed($this->class->name, $fieldName); |
|
129 | } |
|
130 | ||
131 | $mappedByMapping = $this->targetClass->getFieldMapping($referenceMapping['mappedBy']); |
|
132 | switch ($mappedByMapping['storeAs']) { |
|
133 | case ClassMetadataInfo::REFERENCE_STORE_AS_ID: |
|
134 | case ClassMetadataInfo::REFERENCE_STORE_AS_REF: |
|
135 | $referencedFieldName = ClassMetadataInfo::getReferenceFieldName($mappedByMapping['storeAs'], $mappedByMapping['name']); |
|
136 | break; |
|
137 | ||
138 | default: |
|
139 | throw MappingException::cannotLookupDbRefReference($this->class->name, $fieldName); |
|
140 | } |
|
141 | ||
142 | $this |
|
143 | ->localField('_id') |
|
144 | ->foreignField($referencedFieldName); |
|
145 | } |
|
146 | ||
147 | return $this; |
|
148 | } |