em->getRepository($type) ->find($data['id']); } public function supportsDenormalization($data, $type, $format = null) { if (false === \is_array($data)) { return false; } if (false === \array_key_exists('id', $data)) { return false; } if (false === $this->em->getClassMetadata($type) instanceof ClassMetadata) { return false; } // does have serializer metadata, and class discriminator ? if ($this->serializerMetadataFactory->hasMetadataFor($type)) { $classDiscriminator = $this->serializerMetadataFactory ->getMetadataFor($type)->getClassDiscriminatorMapping(); if ($classDiscriminator) { $typeProperty = $classDiscriminator->getTypeProperty(); // check that only 2 keys // that the second key is property // and that the type match the class for given type property return 2 === \count($data) && \array_key_exists($typeProperty, $data) && $classDiscriminator->getClassForType($data[$typeProperty]) === $type; } } // we do not have any class discriminator. Check that the id is the only one key return 1 === \count($data); } }