@@ 369-386 (lines=18) @@ | ||
366 | /* Add a discriminator value if the embedded document is not mapped |
|
367 | * explicitly to a targetDocument class. |
|
368 | */ |
|
369 | if ( ! isset($embeddedMapping['targetDocument'])) { |
|
370 | $discriminatorField = $embeddedMapping['discriminatorField']; |
|
371 | $discriminatorValue = isset($embeddedMapping['discriminatorMap']) |
|
372 | ? array_search($class->name, $embeddedMapping['discriminatorMap']) |
|
373 | : $class->name; |
|
374 | ||
375 | /* If the discriminator value was not found in the map, use the full |
|
376 | * class name. In the future, it may be preferable to throw an |
|
377 | * exception here (perhaps based on some strictness option). |
|
378 | * |
|
379 | * @see DocumentManager::createDBRef() |
|
380 | */ |
|
381 | if ($discriminatorValue === false) { |
|
382 | $discriminatorValue = $class->name; |
|
383 | } |
|
384 | ||
385 | $embeddedDocumentValue[$discriminatorField] = $discriminatorValue; |
|
386 | } |
|
387 | ||
388 | /* If the class has a discriminator (field and value), use it. A child |
|
389 | * class that is not defined in the discriminator map may only have a |
@@ 719-736 (lines=18) @@ | ||
716 | /* Add a discriminator value if the referenced document is not mapped |
|
717 | * explicitly to a targetDocument class. |
|
718 | */ |
|
719 | if (! isset($referenceMapping['targetDocument'])) { |
|
720 | $discriminatorField = $referenceMapping['discriminatorField']; |
|
721 | $discriminatorValue = isset($referenceMapping['discriminatorMap']) |
|
722 | ? array_search($class->name, $referenceMapping['discriminatorMap']) |
|
723 | : $class->name; |
|
724 | ||
725 | /* If the discriminator value was not found in the map, use the full |
|
726 | * class name. In the future, it may be preferable to throw an |
|
727 | * exception here (perhaps based on some strictness option). |
|
728 | * |
|
729 | * @see PersistenceBuilder::prepareEmbeddedDocumentValue() |
|
730 | */ |
|
731 | if ($discriminatorValue === false) { |
|
732 | $discriminatorValue = $class->name; |
|
733 | } |
|
734 | ||
735 | $reference[$discriminatorField] = $discriminatorValue; |
|
736 | } |
|
737 | ||
738 | return $reference; |
|
739 | } |