@@ 70-84 (lines=15) @@ | ||
67 | } |
|
68 | ||
69 | switch ($relationType) { |
|
70 | case Document::RELATION_HAS_ONE: |
|
71 | $localKey = isset($relation['localKey']) ? $relation['localKey'] : '_id'; |
|
72 | $foreignKey = $relation[2]; |
|
73 | ||
74 | $document = $foreignCollection |
|
75 | ->find() |
|
76 | ->where($foreignKey, $this->document->get($localKey)) |
|
77 | ->findOne(); |
|
78 | ||
79 | if ($document) { |
|
80 | $this->resolvedRelationIds[$relationName] = (string) $document->getId(); |
|
81 | } |
|
82 | ||
83 | return $document; |
|
84 | ||
85 | case Document::RELATION_BELONGS: |
|
86 | $localKey = $relation[2]; |
|
87 | $foreignKey = isset($relation['foreignKey']) ? $relation['foreignKey'] : '_id'; |
|
@@ 104-117 (lines=14) @@ | ||
101 | ||
102 | return $document; |
|
103 | ||
104 | case Document::RELATION_HAS_MANY: |
|
105 | $localKey = isset($relation['localKey']) ? $relation['localKey'] : '_id'; |
|
106 | $foreignKey = $relation[2]; |
|
107 | ||
108 | $documents = $foreignCollection |
|
109 | ->find() |
|
110 | ->where($foreignKey, $this->document->get($localKey)) |
|
111 | ->findAll(); |
|
112 | ||
113 | foreach ($documents as $document) { |
|
114 | $this->resolvedRelationIds[$relationName][] = (string) $document->getId(); |
|
115 | } |
|
116 | ||
117 | return $documents; |
|
118 | ||
119 | case Document::RELATION_MANY_MANY: |
|
120 | $isRelationListStoredInternally = isset($relation[3]) && $relation[3]; |