lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
/**
     * Populates the discriminator value of the given metadata (if not set) by iterating over discriminator
     * map classes and looking for a fitting one.
     *
     * @throws InvalidArgumentException
     * @throws ReflectionException
     * @throws MappingException
     */
Populates the discriminator value of the given metadata (if not set) by iterating over discriminator
map classes and looking for a fitting one.


Populates the discriminator value of the given metadata ( if not set ) by iterating over discriminator map classes and looking for a fitting one .
private function resolveDiscriminatorValue(ClassMetadata $metadata) : void
    {
        if ($metadata->discriminatorValue || ! $metadata->discriminatorMap || $metadata->isMappedSuperclass ||
            ! $metadata->getReflectionClass() || $metadata->getReflectionClass()->isAbstract()) {
            return;
        }
        foreach ($metadata->discriminatorMap as $discriminatorValue => $discriminatorClass) {
            if ($discriminatorClass === $metadata->getClassName()) {
                $metadata->discriminatorValue = $discriminatorValue;
                return;
            }
        }
        foreach ($metadata->discriminatorMap as $discriminatorValue => $discriminatorClass) {
            if ($metadata->getClassName() === $this->getMetadataFor($discriminatorClass)->getClassName()) {
                $metadata->discriminatorValue = $discriminatorValue;
                return;
            }
        }
        throw MappingException::mappedClassNotPartOfDiscriminatorMap($metadata->getClassName(), $metadata->getRootClassName());
    }
private function resolveDiscriminatorValue ( ClassMetadata $ metadata ) : void { if ( $ metadata -> discriminatorValue || ! $ metadata -> discriminatorMap || $ metadata -> isMappedSuperclass || ! $ metadata -> getReflectionClass ( ) || $ metadata -> getReflectionClass ( ) -> isAbstract ( ) ) { return ; } foreach ( $ metadata -> discriminatorMap as $ discriminatorValue => $ discriminatorClass ) { if ( $ discriminatorClass === $ metadata -> getClassName ( ) ) { $ metadata -> discriminatorValue = $ discriminatorValue ; return ; } } foreach ( $ metadata -> discriminatorMap as $ discriminatorValue => $ discriminatorClass ) { if ( $ metadata -> getClassName ( ) === $ this -> getMetadataFor ( $ discriminatorClass ) -> getClassName ( ) ) { $ metadata -> discriminatorValue = $ discriminatorValue ; return ; } } throw MappingException :: mappedClassNotPartOfDiscriminatorMap ( $ metadata -> getClassName ( ) , $ metadata -> getRootClassName ( ) ) ; }
Populates the discriminator value of the given metadata (if not set) by iterating over discriminator
 map classes and looking for a fitting one.
Populates the discriminator value of the given metadata ( if not set ) by iterating over discriminator map classes and looking for a fitting one .
// minor optimization: avoid loading related metadata when not needed // iterate over discriminator mappings and resolve actual referenced classes according to existing metadata