|
@@ 235-260 (lines=26) @@
|
| 232 |
|
$mapping['fieldName'], |
| 233 |
|
Type::getType($mapping['type'])->closureToPHP() |
| 234 |
|
); |
| 235 |
|
} elseif ($mapping['association'] === ClassMetadata::REFERENCE_ONE && $mapping['isOwningSide']) { |
| 236 |
|
$code .= sprintf(<<<EOF |
| 237 |
|
|
| 238 |
|
/** @ReferenceOne */ |
| 239 |
|
if (isset(\$data['%1\$s'])) { |
| 240 |
|
\$reference = \$data['%1\$s']; |
| 241 |
|
\$className = \$this->unitOfWork->getClassNameForAssociation(\$this->class->fieldMappings['%2\$s'], \$reference); |
| 242 |
|
\$identifier = ClassMetadataInfo::getReferenceId(\$reference, \$this->class->fieldMappings['%2\$s']['storeAs']); |
| 243 |
|
\$targetMetadata = \$this->dm->getClassMetadata(\$className); |
| 244 |
|
\$id = \$targetMetadata->getPHPIdentifierValue(\$identifier); |
| 245 |
|
\$return = \$this->dm->getReference(\$className, \$id); |
| 246 |
|
\$this->class->reflFields['%2\$s']->setValue(\$document, \$return); |
| 247 |
|
\$hydratedData['%2\$s'] = \$return; |
| 248 |
|
} |
| 249 |
|
|
| 250 |
|
EOF |
| 251 |
|
, |
| 252 |
|
$mapping['name'], |
| 253 |
|
$mapping['fieldName'] |
| 254 |
|
); |
| 255 |
|
} elseif ($mapping['association'] === ClassMetadata::REFERENCE_ONE && $mapping['isInverseSide']) { |
| 256 |
|
if (isset($mapping['repositoryMethod']) && $mapping['repositoryMethod']) { |
| 257 |
|
$code .= sprintf(<<<EOF |
| 258 |
|
|
| 259 |
|
\$className = \$this->class->fieldMappings['%2\$s']['targetDocument']; |
| 260 |
|
\$return = \$this->dm->getRepository(\$className)->%3\$s(\$document); |
| 261 |
|
\$this->class->reflFields['%2\$s']->setValue(\$document, \$return); |
| 262 |
|
\$hydratedData['%2\$s'] = \$return; |
| 263 |
|
|
|
@@ 293-313 (lines=21) @@
|
| 290 |
|
$mapping['fieldName'] |
| 291 |
|
); |
| 292 |
|
} |
| 293 |
|
} elseif ($mapping['association'] === ClassMetadata::REFERENCE_MANY || $mapping['association'] === ClassMetadata::EMBED_MANY) { |
| 294 |
|
$code .= sprintf(<<<EOF |
| 295 |
|
|
| 296 |
|
/** @Many */ |
| 297 |
|
\$mongoData = isset(\$data['%1\$s']) ? \$data['%1\$s'] : null; |
| 298 |
|
\$return = \$this->dm->getConfiguration()->getPersistentCollectionFactory()->create(\$this->dm, \$this->class->fieldMappings['%2\$s']); |
| 299 |
|
\$return->setHints(\$hints); |
| 300 |
|
\$return->setOwner(\$document, \$this->class->fieldMappings['%2\$s']); |
| 301 |
|
\$return->setInitialized(false); |
| 302 |
|
if (\$mongoData) { |
| 303 |
|
\$return->setMongoData(\$mongoData); |
| 304 |
|
} |
| 305 |
|
\$this->class->reflFields['%2\$s']->setValue(\$document, \$return); |
| 306 |
|
\$hydratedData['%2\$s'] = \$return; |
| 307 |
|
|
| 308 |
|
EOF |
| 309 |
|
, |
| 310 |
|
$mapping['name'], |
| 311 |
|
$mapping['fieldName'] |
| 312 |
|
); |
| 313 |
|
} elseif ($mapping['association'] === ClassMetadata::EMBED_ONE) { |
| 314 |
|
$code .= sprintf(<<<EOF |
| 315 |
|
|
| 316 |
|
/** @EmbedOne */ |