| @@ 188-193 (lines=6) @@ | ||
| 185 | $this->document->set($field, $document->getId()); |
|
| 186 | break; |
|
| 187 | ||
| 188 | case Document::RELATION_HAS_ONE; |
|
| 189 | if (!$this->document->isStored()) { |
|
| 190 | throw new \Sokil\Mongo\Exception('Document ' . get_class($this) . ' must be saved before adding relation'); |
|
| 191 | } |
|
| 192 | $document->set($field, $this->document->getId())->save(); |
|
| 193 | break; |
|
| 194 | ||
| 195 | case Document::RELATION_HAS_MANY: |
|
| 196 | if (!$this->document->isStored()) { |
|
| @@ 195-200 (lines=6) @@ | ||
| 192 | $document->set($field, $this->document->getId())->save(); |
|
| 193 | break; |
|
| 194 | ||
| 195 | case Document::RELATION_HAS_MANY: |
|
| 196 | if (!$this->document->isStored()) { |
|
| 197 | throw new \Sokil\Mongo\Exception('Document ' . get_class($this) . ' must be saved before adding relation'); |
|
| 198 | } |
|
| 199 | $document->set($field, $this->document->getId())->save(); |
|
| 200 | break; |
|
| 201 | ||
| 202 | case Document::RELATION_MANY_MANY: |
|
| 203 | $isRelationListStoredInternally = isset($relation[3]) && $relation[3]; |
|
| @@ 233-241 (lines=9) @@ | ||
| 230 | $this->document->set($field, $documentDbRef); |
|
| 231 | break; |
|
| 232 | ||
| 233 | case Document::RELATION_HAS_ONE; |
|
| 234 | if (!$this->document->isStored()) { |
|
| 235 | throw new \Sokil\Mongo\Exception( |
|
| 236 | 'Document '.get_class($this).' must be saved before adding relation' |
|
| 237 | ); |
|
| 238 | } |
|
| 239 | $documentDbRef = self::generateDbRef($this->document); |
|
| 240 | $document->set($field, $documentDbRef)->save(); |
|
| 241 | break; |
|
| 242 | ||
| 243 | case Document::RELATION_HAS_MANY: |
|
| 244 | if (!$this->document->isStored()) { |
|
| @@ 243-251 (lines=9) @@ | ||
| 240 | $document->set($field, $documentDbRef)->save(); |
|
| 241 | break; |
|
| 242 | ||
| 243 | case Document::RELATION_HAS_MANY: |
|
| 244 | if (!$this->document->isStored()) { |
|
| 245 | throw new \Sokil\Mongo\Exception( |
|
| 246 | 'Document '.get_class($this).' must be saved before adding relation' |
|
| 247 | ); |
|
| 248 | } |
|
| 249 | $documentDbRef = self::generateDbRef($this->document); |
|
| 250 | $document->set($field, $documentDbRef)->save(); |
|
| 251 | break; |
|
| 252 | ||
| 253 | case Document::RELATION_MANY_MANY: |
|
| 254 | $isRelationListStoredInternally = isset($relation[3]) && $relation[3]; |
|