| @@ 710-727 (lines=18) @@ | ||
| 707 | /* Add a discriminator value if the referenced document is not mapped |
|
| 708 | * explicitly to a targetDocument class. |
|
| 709 | */ |
|
| 710 | if ($referenceMapping !== null && ! isset($referenceMapping['targetDocument'])) { |
|
| 711 | $discriminatorField = $referenceMapping['discriminatorField']; |
|
| 712 | $discriminatorValue = isset($referenceMapping['discriminatorMap']) |
|
| 713 | ? array_search($class->name, $referenceMapping['discriminatorMap']) |
|
| 714 | : $class->name; |
|
| 715 | ||
| 716 | /* If the discriminator value was not found in the map, use the full |
|
| 717 | * class name. In the future, it may be preferable to throw an |
|
| 718 | * exception here (perhaps based on some strictness option). |
|
| 719 | * |
|
| 720 | * @see PersistenceBuilder::prepareEmbeddedDocumentValue() |
|
| 721 | */ |
|
| 722 | if ($discriminatorValue === false) { |
|
| 723 | $discriminatorValue = $class->name; |
|
| 724 | } |
|
| 725 | ||
| 726 | $dbRef[$discriminatorField] = $discriminatorValue; |
|
| 727 | } |
|
| 728 | ||
| 729 | return $dbRef; |
|
| 730 | } |
|
| @@ 399-416 (lines=18) @@ | ||
| 396 | /* Add a discriminator value if the embedded document is not mapped |
|
| 397 | * explicitly to a targetDocument class. |
|
| 398 | */ |
|
| 399 | if ( ! isset($embeddedMapping['targetDocument'])) { |
|
| 400 | $discriminatorField = $embeddedMapping['discriminatorField']; |
|
| 401 | $discriminatorValue = isset($embeddedMapping['discriminatorMap']) |
|
| 402 | ? array_search($class->name, $embeddedMapping['discriminatorMap']) |
|
| 403 | : $class->name; |
|
| 404 | ||
| 405 | /* If the discriminator value was not found in the map, use the full |
|
| 406 | * class name. In the future, it may be preferable to throw an |
|
| 407 | * exception here (perhaps based on some strictness option). |
|
| 408 | * |
|
| 409 | * @see DocumentManager::createDBRef() |
|
| 410 | */ |
|
| 411 | if ($discriminatorValue === false) { |
|
| 412 | $discriminatorValue = $class->name; |
|
| 413 | } |
|
| 414 | ||
| 415 | $embeddedDocumentValue[$discriminatorField] = $discriminatorValue; |
|
| 416 | } |
|
| 417 | ||
| 418 | /* If the class has a discriminator (field and value), use it. A child |
|
| 419 | * class that is not defined in the discriminator map may only have a |
|