| @@ 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 |
|
| @@ 723-740 (lines=18) @@ | ||
| 720 | /* Add a discriminator value if the referenced document is not mapped |
|
| 721 | * explicitly to a targetDocument class. |
|
| 722 | */ |
|
| 723 | if ($referenceMapping !== null && ! isset($referenceMapping['targetDocument'])) { |
|
| 724 | $discriminatorField = $referenceMapping['discriminatorField']; |
|
| 725 | $discriminatorValue = isset($referenceMapping['discriminatorMap']) |
|
| 726 | ? array_search($class->name, $referenceMapping['discriminatorMap']) |
|
| 727 | : $class->name; |
|
| 728 | ||
| 729 | /* If the discriminator value was not found in the map, use the full |
|
| 730 | * class name. In the future, it may be preferable to throw an |
|
| 731 | * exception here (perhaps based on some strictness option). |
|
| 732 | * |
|
| 733 | * @see PersistenceBuilder::prepareEmbeddedDocumentValue() |
|
| 734 | */ |
|
| 735 | if ($discriminatorValue === false) { |
|
| 736 | $discriminatorValue = $class->name; |
|
| 737 | } |
|
| 738 | ||
| 739 | $dbRef[$discriminatorField] = $discriminatorValue; |
|
| 740 | } |
|
| 741 | ||
| 742 | return $dbRef; |
|
| 743 | } |
|