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