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