Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cde5dde

Browse filesBrowse files
committed
Merge branch '4.2' into 4.3
* 4.2: Tweaks. refs #11439 custom encoders interface signature
2 parents eac4d52 + 4f31753 commit cde5dde
Copy full SHA for cde5dde

File tree

1 file changed

+10
-2
lines changed
Filter options

1 file changed

+10
-2
lines changed

‎serializer/custom_encoders.rst

Copy file name to clipboardExpand all lines: serializer/custom_encoders.rst
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ create your own encoder that uses the
3232
return Yaml::dump($data);
3333
}
3434

35-
public function supportsEncoding($format, array $context = [])
35+
public function supportsEncoding($format)
3636
{
3737
return 'yaml' === $format;
3838
}
@@ -42,12 +42,20 @@ create your own encoder that uses the
4242
return Yaml::parse($data);
4343
}
4444

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

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.