@@ 390-407 (lines=18) @@ | ||
387 | /* Add a discriminator value if the embedded document is not mapped |
|
388 | * explicitly to a targetDocument class. |
|
389 | */ |
|
390 | if ( ! isset($embeddedMapping['targetDocument'])) { |
|
391 | $discriminatorField = $embeddedMapping['discriminatorField']; |
|
392 | $discriminatorValue = isset($embeddedMapping['discriminatorMap']) |
|
393 | ? array_search($class->name, $embeddedMapping['discriminatorMap']) |
|
394 | : $class->name; |
|
395 | ||
396 | /* If the discriminator value was not found in the map, use the full |
|
397 | * class name. In the future, it may be preferable to throw an |
|
398 | * exception here (perhaps based on some strictness option). |
|
399 | * |
|
400 | * @see DocumentManager::createDBRef() |
|
401 | */ |
|
402 | if ($discriminatorValue === false) { |
|
403 | $discriminatorValue = $class->name; |
|
404 | } |
|
405 | ||
406 | $embeddedDocumentValue[$discriminatorField] = $discriminatorValue; |
|
407 | } |
|
408 | ||
409 | /* If the class has a discriminator (field and value), use it. A child |
|
410 | * class that is not defined in the discriminator map may only have a |
@@ 745-762 (lines=18) @@ | ||
742 | /* Add a discriminator value if the referenced document is not mapped |
|
743 | * explicitly to a targetDocument class. |
|
744 | */ |
|
745 | if (! isset($referenceMapping['targetDocument'])) { |
|
746 | $discriminatorField = $referenceMapping['discriminatorField']; |
|
747 | $discriminatorValue = isset($referenceMapping['discriminatorMap']) |
|
748 | ? array_search($class->name, $referenceMapping['discriminatorMap']) |
|
749 | : $class->name; |
|
750 | ||
751 | /* If the discriminator value was not found in the map, use the full |
|
752 | * class name. In the future, it may be preferable to throw an |
|
753 | * exception here (perhaps based on some strictness option). |
|
754 | * |
|
755 | * @see PersistenceBuilder::prepareEmbeddedDocumentValue() |
|
756 | */ |
|
757 | if ($discriminatorValue === false) { |
|
758 | $discriminatorValue = $class->name; |
|
759 | } |
|
760 | ||
761 | $reference[$discriminatorField] = $discriminatorValue; |
|
762 | } |
|
763 | ||
764 | return $reference; |
|
765 | } |