Skip to content

Commit 4cb3aba

Browse files
authored
Merge pull request #353 from beleneglorion/fix-normalizer
Fix missing serializer in decorated normalizer
2 parents 1355a46 + 0bc62cf commit 4cb3aba

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

core/serialization.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,10 @@ namespace AppBundle\Serializer;
423423
424424
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
425425
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
426+
use Symfony\Component\Serializer\SerializerAwareInterface;
427+
use Symfony\Component\Serializer\SerializerInterface;
426428
427-
final class ApiNormalizer implements NormalizerInterface, DenormalizerInterface
429+
final class ApiNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface
428430
{
429431
private $decorated;
430432
@@ -461,6 +463,13 @@ final class ApiNormalizer implements NormalizerInterface, DenormalizerInterface
461463
{
462464
return $this->decorated->denormalize($data, $class, $format, $context);
463465
}
466+
467+
public function setSerializer(SerializerInterface $serializer)
468+
{
469+
if($this->decorated instanceof SerializerAwareInterface) {
470+
$this->decorated->setSerializer($serializer);
471+
}
472+
}
464473
}
465474
```
466475

0 commit comments

Comments
 (0)