Skip to content

Commit

Permalink
Fix #10: Actually check the $type is supported by `CustomNormalizer…
Browse files Browse the repository at this point in the history
…`. (#11)
  • Loading branch information
Aerendir authored Sep 3, 2023
1 parent 459e321 commit aa4b85e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Serializer/Normalizer/CustomNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Prugala\RequestDto\Serializer\Normalizer;

use Prugala\RequestDto\Dto\RequestDtoInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorResolverInterface;
Expand Down Expand Up @@ -32,4 +34,12 @@ public function supportsNormalization(mixed $data, string $format = null)
{
return false;
}

public function supportsDenormalization(mixed $data, string $type, string $format = null){
if (false === parent::supportsDenormalization($data, $type, $format)) {
return false;
}

return is_a($type, Request::class, true) || is_a($type, RequestDtoInterface::class, true);
}
}

0 comments on commit aa4b85e

Please sign in to comment.