@@ 247-272 (lines=26) @@ | ||
244 | $mapping['fieldName'], |
|
245 | Type::getType($mapping['type'])->closureToPHP() |
|
246 | ); |
|
247 | } elseif ($mapping['association'] === ClassMetadata::REFERENCE_ONE && $mapping['isOwningSide']) { |
|
248 | $code .= sprintf(<<<EOF |
|
249 | ||
250 | /** @ReferenceOne */ |
|
251 | if (isset(\$data['%1\$s'])) { |
|
252 | \$reference = \$data['%1\$s']; |
|
253 | if (isset(\$this->class->fieldMappings['%2\$s']['simple']) && \$this->class->fieldMappings['%2\$s']['simple']) { |
|
254 | \$className = \$this->class->fieldMappings['%2\$s']['targetDocument']; |
|
255 | \$mongoId = \$reference; |
|
256 | } else { |
|
257 | \$className = \$this->unitOfWork->getClassNameForAssociation(\$this->class->fieldMappings['%2\$s'], \$reference); |
|
258 | \$mongoId = \$reference['\$id']; |
|
259 | } |
|
260 | \$targetMetadata = \$this->dm->getClassMetadata(\$className); |
|
261 | \$id = \$targetMetadata->getPHPIdentifierValue(\$mongoId); |
|
262 | \$return = \$this->dm->getReference(\$className, \$id); |
|
263 | \$this->class->reflFields['%2\$s']->setValue(\$document, \$return); |
|
264 | \$hydratedData['%2\$s'] = \$return; |
|
265 | } |
|
266 | ||
267 | EOF |
|
268 | , |
|
269 | $mapping['name'], |
|
270 | $mapping['fieldName'] |
|
271 | ); |
|
272 | } elseif ($mapping['association'] === ClassMetadata::REFERENCE_ONE && $mapping['isInverseSide']) { |
|
273 | if (isset($mapping['repositoryMethod']) && $mapping['repositoryMethod']) { |
|
274 | $code .= sprintf(<<<EOF |
|
275 | ||
@@ 310-330 (lines=21) @@ | ||
307 | $mapping['fieldName'] |
|
308 | ); |
|
309 | } |
|
310 | } elseif ($mapping['association'] === ClassMetadata::REFERENCE_MANY || $mapping['association'] === ClassMetadata::EMBED_MANY) { |
|
311 | $code .= sprintf(<<<EOF |
|
312 | ||
313 | /** @Many */ |
|
314 | \$mongoData = isset(\$data['%1\$s']) ? \$data['%1\$s'] : null; |
|
315 | \$return = new \Doctrine\ODM\MongoDB\PersistentCollection(new \Doctrine\Common\Collections\ArrayCollection(), \$this->dm, \$this->unitOfWork); |
|
316 | \$return->setHints(\$hints); |
|
317 | \$return->setOwner(\$document, \$this->class->fieldMappings['%2\$s']); |
|
318 | \$return->setInitialized(false); |
|
319 | if (\$mongoData) { |
|
320 | \$return->setMongoData(\$mongoData); |
|
321 | } |
|
322 | \$this->class->reflFields['%2\$s']->setValue(\$document, \$return); |
|
323 | \$hydratedData['%2\$s'] = \$return; |
|
324 | ||
325 | EOF |
|
326 | , |
|
327 | $mapping['name'], |
|
328 | $mapping['fieldName'] |
|
329 | ); |
|
330 | } elseif ($mapping['association'] === ClassMetadata::EMBED_ONE) { |
|
331 | $code .= sprintf(<<<EOF |
|
332 | ||
333 | /** @EmbedOne */ |