|
@@ 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 = \$this->dm->getConfiguration()->getPersistentCollectionFactory()->create(\$this->dm, \$this->class->fieldMappings['%2\$s']); |
| 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 */ |
|
@@ 252-277 (lines=26) @@
|
| 249 |
|
$mapping['fieldName'], |
| 250 |
|
Type::getType($mapping['type'])->closureToPHP() |
| 251 |
|
); |
| 252 |
|
} elseif ($mapping['association'] === ClassMetadata::REFERENCE_ONE && $mapping['isOwningSide']) { |
| 253 |
|
$code .= sprintf(<<<EOF |
| 254 |
|
|
| 255 |
|
/** @ReferenceOne */ |
| 256 |
|
if (isset(\$data['%1\$s'])) { |
| 257 |
|
\$reference = \$data['%1\$s']; |
| 258 |
|
\$className = \$this->unitOfWork->getClassNameForAssociation(\$this->class->fieldMappings['%2\$s'], \$reference); |
| 259 |
|
\$mongoId = ClassMetadataInfo::getReferenceId(\$reference, \$this->class->fieldMappings['%2\$s']['storeAs']); |
| 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 |
|
|
| 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); |
| 279 |
|
\$hydratedData['%2\$s'] = \$return; |
| 280 |
|
|