diff --git a/serializer/custom_normalizer.rst b/serializer/custom_normalizer.rst index fa7aa1f0094..9241aee8216 100644 --- a/serializer/custom_normalizer.rst +++ b/serializer/custom_normalizer.rst @@ -22,18 +22,20 @@ to customize the normalized data. To do that, leverage the ``ObjectNormalizer``: use App\Entity\Topic; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; + use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; - class TopicNormalizer implements NormalizerInterface + class TopicNormalizer implements NormalizerInterface, NormalizerAwareInterface { + use NormalizerAwareTrait; + private $router; private $normalizer; - public function __construct(UrlGeneratorInterface $router, ObjectNormalizer $normalizer) + public function __construct(UrlGeneratorInterface $router) { $this->router = $router; - $this->normalizer = $normalizer; } public function normalize($topic, string $format = null, array $context = [])