diff --git a/controller/error_pages.rst b/controller/error_pages.rst index a94294573a0..ce582378c82 100644 --- a/controller/error_pages.rst +++ b/controller/error_pages.rst @@ -226,7 +226,7 @@ contents, create a new Normalizer that supports the ``FlattenException`` input:: ]; } - public function supportsNormalization($data, string $format = null) + public function supportsNormalization($data, string $format = null, array $context = []) { return $data instanceof FlattenException; } diff --git a/serializer/custom_encoders.rst b/serializer/custom_encoders.rst index 7f8a0e1b4f2..1fabd9b2b4d 100644 --- a/serializer/custom_encoders.rst +++ b/serializer/custom_encoders.rst @@ -33,7 +33,7 @@ create your own encoder that uses the return Yaml::dump($data); } - public function supportsEncoding(string $format) + public function supportsEncoding(string $format, array $context = []) { return 'yaml' === $format; } @@ -43,19 +43,12 @@ create your own encoder that uses the return Yaml::parse($data); } - public function supportsDecoding(string $format) + public function supportsDecoding(string $format, array $context = []) { return 'yaml' === $format; } } -.. tip:: - - If you need access to ``$context`` in your ``supportsDecoding`` or - ``supportsEncoding`` method, make sure to implement - ``Symfony\Component\Serializer\Encoder\ContextAwareDecoderInterface`` - or ``Symfony\Component\Serializer\Encoder\ContextAwareEncoderInterface`` accordingly. - Registering it in your app -------------------------- diff --git a/serializer/custom_normalizer.rst b/serializer/custom_normalizer.rst index 5630eb4e552..fa7aa1f0094 100644 --- a/serializer/custom_normalizer.rst +++ b/serializer/custom_normalizer.rst @@ -22,10 +22,10 @@ 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\ContextAwareNormalizerInterface; + use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; - class TopicNormalizer implements ContextAwareNormalizerInterface + class TopicNormalizer implements NormalizerInterface { private $router; private $normalizer;