mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
fix normalisation of AccompanyingCourse requestor api
This commit is contained in:
parent
91ba08dfa1
commit
f43e216e13
@ -12,6 +12,7 @@ declare(strict_types=1);
|
|||||||
namespace Chill\MainBundle\Serializer\Normalizer;
|
namespace Chill\MainBundle\Serializer\Normalizer;
|
||||||
|
|
||||||
use LogicException;
|
use LogicException;
|
||||||
|
use Symfony\Component\Serializer\Exception\NotNormalizableValueException;
|
||||||
use Symfony\Component\Serializer\Exception\RuntimeException;
|
use Symfony\Component\Serializer\Exception\RuntimeException;
|
||||||
use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface;
|
use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface;
|
||||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
|
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
|
||||||
@ -44,7 +45,7 @@ class DiscriminatedObjectDenormalizer implements ContextAwareDenormalizerInterfa
|
|||||||
if ($this->denormalizer->supportsDenormalization($data, $localType, $format)) {
|
if ($this->denormalizer->supportsDenormalization($data, $localType, $format)) {
|
||||||
try {
|
try {
|
||||||
return $this->denormalizer->denormalize($data, $localType, $format, $context);
|
return $this->denormalizer->denormalize($data, $localType, $format, $context);
|
||||||
} catch (RuntimeException $e) {
|
} catch (RuntimeException|NotNormalizableValueException $e) {
|
||||||
$lastException = $e;
|
$lastException = $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ use Chill\MainBundle\Entity\Scope;
|
|||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\MainBundle\Serializer\Model\Collection;
|
use Chill\MainBundle\Serializer\Model\Collection;
|
||||||
use Chill\MainBundle\Serializer\Model\Counter;
|
use Chill\MainBundle\Serializer\Model\Counter;
|
||||||
|
use Chill\MainBundle\Serializer\Normalizer\DiscriminatedObjectDenormalizer;
|
||||||
use Chill\PersonBundle\AccompanyingPeriod\Suggestion\ReferralsSuggestionInterface;
|
use Chill\PersonBundle\AccompanyingPeriod\Suggestion\ReferralsSuggestionInterface;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||||
@ -235,13 +236,12 @@ final class AccompanyingCourseApiController extends ApiController
|
|||||||
$exceptions = [];
|
$exceptions = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$contentAsArray = json_decode($request->getContent(), true);
|
$requestor = $this->getSerializer()->deserialize(
|
||||||
$entityType = $contentAsArray['type'];
|
$request->getContent(),
|
||||||
if ($entityType === 'person') {
|
'@multi',
|
||||||
$requestor = $this->getSerializer()->deserialize($request->getContent(), Person::class, $_format, []);
|
$_format,
|
||||||
} elseif ($entityType === 'thirdparty') {
|
[DiscriminatedObjectDenormalizer::ALLOWED_TYPES => [Person::class, ThirdParty::class]]
|
||||||
$requestor = $this->getSerializer()->deserialize($request->getContent(), ThirdParty::class, $_format, []);
|
);
|
||||||
}
|
|
||||||
} catch (RuntimeException $e) {
|
} catch (RuntimeException $e) {
|
||||||
$exceptions[] = $e;
|
$exceptions[] = $e;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user