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