|
@@ 79-99 (lines=21) @@
|
| 76 |
|
$dbRef = $this->dm->createReference($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 |
|
@trigger_error('Calling ' . __METHOD__ . ' without a current field set will no longer be possible in ODM 2.0.', E_USER_DEPRECATED); |
| 102 |
|
|
|
@@ 123-143 (lines=21) @@
|
| 120 |
|
$dbRef = $this->dm->createReference($document, $mapping); |
| 121 |
|
$storeAs = array_key_exists('storeAs', $mapping) ? $mapping['storeAs'] : null; |
| 122 |
|
|
| 123 |
|
if ($storeAs === ClassMetadataInfo::REFERENCE_STORE_AS_ID) { |
| 124 |
|
$this->query[$mapping['name']] = $dbRef; |
| 125 |
|
} else { |
| 126 |
|
if ($storeAs === ClassMetadataInfo::REFERENCE_STORE_AS_REF) { |
| 127 |
|
$keys = ['id' => true]; |
| 128 |
|
} else { |
| 129 |
|
$keys = ['$ref' => true, '$id' => true, '$db' => true]; |
| 130 |
|
|
| 131 |
|
if ($storeAs === ClassMetadataInfo::REFERENCE_STORE_AS_DB_REF) { |
| 132 |
|
unset($keys['$db']); |
| 133 |
|
} |
| 134 |
|
|
| 135 |
|
if (isset($mapping['targetDocument'])) { |
| 136 |
|
unset($keys['$ref'], $keys['$db']); |
| 137 |
|
} |
| 138 |
|
} |
| 139 |
|
|
| 140 |
|
foreach ($keys as $key => $value) { |
| 141 |
|
$this->query[$mapping['name']]['$elemMatch'][$key] = $dbRef[$key]; |
| 142 |
|
} |
| 143 |
|
} |
| 144 |
|
} else { |
| 145 |
|
@trigger_error('Calling ' . __METHOD__ . ' without a current field set will no longer be possible in ODM 2.0.', E_USER_DEPRECATED); |
| 146 |
|
|