@@ 223-231 (lines=9) @@ | ||
220 | ||
221 | switch ($relationType) { |
|
222 | ||
223 | case Document::RELATION_BELONGS: |
|
224 | if (!$document->isStored()) { |
|
225 | throw new \Sokil\Mongo\Exception( |
|
226 | 'Document '.get_class($document).' must be saved before adding relation' |
|
227 | ); |
|
228 | } |
|
229 | $documentDbRef = self::generateDbRef($document); |
|
230 | $this->document->set($field, $documentDbRef); |
|
231 | break; |
|
232 | ||
233 | case Document::RELATION_HAS_ONE; |
|
234 | if (!$this->document->isStored()) { |
@@ 181-186 (lines=6) @@ | ||
178 | ||
179 | switch ($relationType) { |
|
180 | ||
181 | case Document::RELATION_BELONGS: |
|
182 | if (!$document->isStored()) { |
|
183 | throw new \Sokil\Mongo\Exception('Document ' . get_class($document) . ' must be saved before adding relation'); |
|
184 | } |
|
185 | $this->document->set($field, $document->getId()); |
|
186 | break; |
|
187 | ||
188 | case Document::RELATION_HAS_ONE; |
|
189 | if (!$this->document->isStored()) { |