| @@ 201-226 (lines=26) @@ | ||
| 198 | * |
|
| 199 | * @return $this |
|
| 200 | */ |
|
| 201 | public function from($from) |
|
| 202 | { |
|
| 203 | // $from can either be |
|
| 204 | // a) a field name indicating a reference to a different document. Currently, only REFERENCE_STORE_AS_ID is supported |
|
| 205 | // b) a Class name |
|
| 206 | // c) a collection name |
|
| 207 | // In cases b) and c) the local and foreign fields need to be filled |
|
| 208 | if ($this->class->hasReference($from)) { |
|
| 209 | return $this->fromReference($from); |
|
| 210 | } |
|
| 211 | ||
| 212 | // Check if mapped class with given name exists |
|
| 213 | try { |
|
| 214 | $this->targetClass = $this->dm->getClassMetadata($from); |
|
| 215 | } catch (BaseMappingException $e) { |
|
| 216 | $this->from = $from; |
|
| 217 | return $this; |
|
| 218 | } |
|
| 219 | ||
| 220 | if ($this->targetClass->isSharded()) { |
|
| 221 | throw MappingException::cannotUseShardedCollectionInLookupStages($this->targetClass->name); |
|
| 222 | } |
|
| 223 | ||
| 224 | $this->from = $this->targetClass->getCollection(); |
|
| 225 | return $this; |
|
| 226 | } |
|
| 227 | ||
| 228 | /** |
|
| 229 | * {@inheritdoc} |
|
| @@ 113-138 (lines=26) @@ | ||
| 110 | * |
|
| 111 | * @return $this |
|
| 112 | */ |
|
| 113 | public function from($from) |
|
| 114 | { |
|
| 115 | // $from can either be |
|
| 116 | // a) a field name indicating a reference to a different document. Currently, only REFERENCE_STORE_AS_ID is supported |
|
| 117 | // b) a Class name |
|
| 118 | // c) a collection name |
|
| 119 | // In cases b) and c) the local and foreign fields need to be filled |
|
| 120 | if ($this->class->hasReference($from)) { |
|
| 121 | return $this->fromReference($from); |
|
| 122 | } |
|
| 123 | ||
| 124 | // Check if mapped class with given name exists |
|
| 125 | try { |
|
| 126 | $this->targetClass = $this->dm->getClassMetadata($from); |
|
| 127 | } catch (BaseMappingException $e) { |
|
| 128 | $this->from = $from; |
|
| 129 | return $this; |
|
| 130 | } |
|
| 131 | ||
| 132 | if ($this->targetClass->isSharded()) { |
|
| 133 | throw MappingException::cannotUseShardedCollectionInLookupStages($this->targetClass->name); |
|
| 134 | } |
|
| 135 | ||
| 136 | $this->from = $this->targetClass->getCollection(); |
|
| 137 | return $this; |
|
| 138 | } |
|
| 139 | ||
| 140 | /** |
|
| 141 | * {@inheritdoc} |
|