Skip to content

Commit f544565

Browse files
committed
minor #16386 [Serializer] Deprecate context aware interfaces (mtarld)
This PR was merged into the 6.1 branch. Discussion ---------- [Serializer] Deprecate context aware interfaces Related to and closes #16380 Commits ------- 18ae527 [Serializer] Deprecate "context aware" interfaces
2 parents d934a4e + 18ae527 commit f544565

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

controller/error_pages.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ contents, create a new Normalizer that supports the ``FlattenException`` input::
226226
];
227227
}
228228

229-
public function supportsNormalization($data, string $format = null)
229+
public function supportsNormalization($data, string $format = null, array $context = [])
230230
{
231231
return $data instanceof FlattenException;
232232
}

serializer/custom_encoders.rst

+2-9
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ create your own encoder that uses the
3333
return Yaml::dump($data);
3434
}
3535

36-
public function supportsEncoding(string $format)
36+
public function supportsEncoding(string $format, array $context = [])
3737
{
3838
return 'yaml' === $format;
3939
}
@@ -43,19 +43,12 @@ create your own encoder that uses the
4343
return Yaml::parse($data);
4444
}
4545

46-
public function supportsDecoding(string $format)
46+
public function supportsDecoding(string $format, array $context = [])
4747
{
4848
return 'yaml' === $format;
4949
}
5050
}
5151

52-
.. tip::
53-
54-
If you need access to ``$context`` in your ``supportsDecoding`` or
55-
``supportsEncoding`` method, make sure to implement
56-
``Symfony\Component\Serializer\Encoder\ContextAwareDecoderInterface``
57-
or ``Symfony\Component\Serializer\Encoder\ContextAwareEncoderInterface`` accordingly.
58-
5952

6053
Registering it in your app
6154
--------------------------

serializer/custom_normalizer.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ to customize the normalized data. To do that, leverage the ``ObjectNormalizer``:
2222

2323
use App\Entity\Topic;
2424
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
25-
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
25+
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
2626
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
2727

28-
class TopicNormalizer implements ContextAwareNormalizerInterface
28+
class TopicNormalizer implements NormalizerInterface
2929
{
3030
private $router;
3131
private $normalizer;

0 commit comments

Comments
 (0)