@@ 79-99 (lines=21) @@ | ||
76 | $dbRef = $this->dm->createDBRef($document, $mapping); |
|
77 | $storeAs = array_key_exists('storeAs', $mapping) ? $mapping['storeAs'] : null; |
|
78 | ||
79 | if ($storeAs === ClassMetadataInfo::REFERENCE_STORE_AS_ID) { |
|
80 | $this->query[$mapping['name']] = $dbRef; |
|
81 | } else { |
|
82 | if ($storeAs === ClassMetadataInfo::REFERENCE_STORE_AS_REF) { |
|
83 | $keys = ['id' => true]; |
|
84 | } else { |
|
85 | $keys = ['$ref' => true, '$id' => true, '$db' => true]; |
|
86 | ||
87 | if ($storeAs === ClassMetadataInfo::REFERENCE_STORE_AS_DB_REF) { |
|
88 | unset($keys['$db']); |
|
89 | } |
|
90 | ||
91 | if (isset($mapping['targetDocument'])) { |
|
92 | unset($keys['$ref'], $keys['$db']); |
|
93 | } |
|
94 | } |
|
95 | ||
96 | foreach ($keys as $key => $value) { |
|
97 | $this->query[$mapping['name'] . '.' . $key] = $dbRef[$key]; |
|
98 | } |
|
99 | } |
|
100 | } else { |
|
101 | $dbRef = $this->dm->createDBRef($document); |
|
102 | $this->query = $dbRef; |
|
@@ 121-141 (lines=21) @@ | ||
118 | $dbRef = $this->dm->createDBRef($document, $mapping); |
|
119 | $storeAs = array_key_exists('storeAs', $mapping) ? $mapping['storeAs'] : null; |
|
120 | ||
121 | if ($storeAs === ClassMetadataInfo::REFERENCE_STORE_AS_ID) { |
|
122 | $this->query[$mapping['name']] = $dbRef; |
|
123 | } else { |
|
124 | if ($storeAs === ClassMetadataInfo::REFERENCE_STORE_AS_REF) { |
|
125 | $keys = ['id' => true]; |
|
126 | } else { |
|
127 | $keys = ['$ref' => true, '$id' => true, '$db' => true]; |
|
128 | ||
129 | if ($storeAs === ClassMetadataInfo::REFERENCE_STORE_AS_DB_REF) { |
|
130 | unset($keys['$db']); |
|
131 | } |
|
132 | ||
133 | if (isset($mapping['targetDocument'])) { |
|
134 | unset($keys['$ref'], $keys['$db']); |
|
135 | } |
|
136 | } |
|
137 | ||
138 | foreach ($keys as $key => $value) { |
|
139 | $this->query[$mapping['name']]['$elemMatch'][$key] = $dbRef[$key]; |
|
140 | } |
|
141 | } |
|
142 | } else { |
|
143 | $dbRef = $this->dm->createDBRef($document); |
|
144 | $this->query['$elemMatch'] = $dbRef; |