You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes the documentation about encoders that was wrong.
Using `Symfony\Component\Serializer\Encoder\EncoderInterface` no `$context` parameter is passed to `supportsEncoding` method. YOu have to use the ContextAware version of it.
Copy file name to clipboardExpand all lines: serializer/custom_encoders.rst
+8-2Lines changed: 8 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ create your own encoder that uses the
32
32
return Yaml::dump($data);
33
33
}
34
34
35
-
public function supportsEncoding($format, array $context = [])
35
+
public function supportsEncoding($format)
36
36
{
37
37
return 'yaml' === $format;
38
38
}
@@ -42,12 +42,18 @@ create your own encoder that uses the
42
42
return Yaml::parse($data);
43
43
}
44
44
45
-
public function supportsDecoding($format, array $context = [])
45
+
public function supportsDecoding($format)
46
46
{
47
47
return 'yaml' === $format;
48
48
}
49
49
}
50
50
51
+
.. tip::
52
+
53
+
If you need access to ``$context`` in your ``supportsDecoding`` or ``supportsEncoding`` method, make sure
54
+
to implements ``Symfony\Component\Serializer\Encoder\ContextAwareEncoderInterface`` or ``Symfony\Component\Serializer\Encoder\ContextAwareEncoderInterface`` interface
0 commit comments