src/Listener/SerializationSubscriber.php
public function onPreDeserialize(PreDeserializeEvent $event)
    {
        $class = $event->getType()['name'];

        if (!class_exists($class)) {
            return; // skip custom JMS types
        }

        $data   = $event->getData();
        $object = new \ReflectionClass($class);

        $discriminator = $this->reader->getClassAnnotation($object, Discriminator::class);

        if ($discriminator) {
            $event->setType($discriminator->getClass($data));
        }
    }
public function onPreDeserialize(PreDeserializeEvent $event)
    {
        $class = $event->getType()['name'];

        if (!class_exists($class)) {
            return; // skip custom JMS types
        }

        $data   = $event->getData();
        $object = new \ReflectionClass($class);

        $discriminator = $this->reader->getClassAnnotation($object, Discriminator::class);

        if ($discriminator) {
            $event->setType($discriminator->getClass($data));
        }
    }
public function onPreDeserialize ( PreDeserializeEvent $ event ) { $ class = $ event -> getType ( ) [ 'name' ] ; if ( ! class_exists ( $ class ) ) { return ; // skip custom JMS types } $ data = $ event -> getData ( ) ; $ object = new \ ReflectionClass ( $ class ) ; $ discriminator = $ this -> reader -> getClassAnnotation ( $ object , Discriminator :: class ) ; if ( $ discriminator ) { $ event -> setType ( $ discriminator -> getClass ( $ data ) ) ; } }
Checks for the existence of a discriminator annotation and sets the
corresponding mapped deserialization class

@param PreDeserializeEvent $event
Checks for the existence of a discriminator annotation and sets the corresponding mapped deserialization class