|
@@ 116-130 (lines=15) @@
|
| 113 |
|
|
| 114 |
|
switch ($relationType) { |
| 115 |
|
|
| 116 |
|
case Document::RELATION_HAS_ONE: |
| 117 |
|
$foreignKey = $relation[2]; |
| 118 |
|
|
| 119 |
|
$documentDbRef = self::generateDbRef($this->document); |
| 120 |
|
|
| 121 |
|
$document = $foreignCollection |
| 122 |
|
->find() |
| 123 |
|
->where($foreignKey.'.$id', $this->extractMongoIdFromDbRef($documentDbRef)) |
| 124 |
|
->findOne(); |
| 125 |
|
|
| 126 |
|
if ($document) { |
| 127 |
|
$this->resolvedRelationIds[$relationName] = (string)$document->getId(); |
| 128 |
|
} |
| 129 |
|
|
| 130 |
|
return $document; |
| 131 |
|
|
| 132 |
|
case Document::RELATION_BELONGS: |
| 133 |
|
$document = null; |
|
@@ 132-144 (lines=13) @@
|
| 129 |
|
|
| 130 |
|
return $document; |
| 131 |
|
|
| 132 |
|
case Document::RELATION_BELONGS: |
| 133 |
|
$document = null; |
| 134 |
|
|
| 135 |
|
$localKey = $relation[2]; |
| 136 |
|
|
| 137 |
|
$dbRef = $this->document->get($localKey); |
| 138 |
|
$document = $foreignCollection->getDocument($this->extractMongoIdFromDbRef($dbRef)); |
| 139 |
|
|
| 140 |
|
if ($document) { |
| 141 |
|
$this->resolvedRelationIds[$relationName] = (string)$document->getId(); |
| 142 |
|
} |
| 143 |
|
|
| 144 |
|
return $document; |
| 145 |
|
|
| 146 |
|
case Document::RELATION_HAS_MANY: |
| 147 |
|
$foreignKey = $relation[2]; |
|
@@ 146-159 (lines=14) @@
|
| 143 |
|
|
| 144 |
|
return $document; |
| 145 |
|
|
| 146 |
|
case Document::RELATION_HAS_MANY: |
| 147 |
|
$foreignKey = $relation[2]; |
| 148 |
|
|
| 149 |
|
$documentDbRef = self::generateDbRef($this->document); |
| 150 |
|
$documents = $foreignCollection |
| 151 |
|
->find() |
| 152 |
|
->where($foreignKey.'.$id', $this->extractMongoIdFromDbRef($documentDbRef)) |
| 153 |
|
->findAll(); |
| 154 |
|
|
| 155 |
|
foreach ($documents as $document) { |
| 156 |
|
$this->resolvedRelationIds[$relationName][] = (string)$document->getId(); |
| 157 |
|
} |
| 158 |
|
|
| 159 |
|
return $documents; |
| 160 |
|
|
| 161 |
|
case Document::RELATION_MANY_MANY: |
| 162 |
|
$isRelationListStoredInternally = isset($relation[3]) && $relation[3]; |