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

[Serialized] add context to serialize and deserialize #26043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 1 src/Symfony/Component/Serializer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CHANGELOG
* added getter for extra attributes in `ExtraAttributesException`
* improved `CsvEncoder` to handle variable nested structures
* CSV headers can be passed to the `CsvEncoder` via the `csv_headers` serialization context variable
* added `$context` when checking for encoding, decoding and normalizing in `Serializer`

3.3.0
-----
Expand Down
6 changes: 3 additions & 3 deletions 6 src/Symfony/Component/Serializer/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ public function __construct(array $normalizers = array(), array $encoders = arra
*/
final public function serialize($data, $format, array $context = array())
{
if (!$this->supportsEncoding($format)) {
if (!$this->supportsEncoding($format, $context)) {
throw new NotEncodableValueException(sprintf('Serialization for the format %s is not supported', $format));
}

if ($this->encoder->needsNormalization($format)) {
if ($this->encoder->needsNormalization($format, $context)) {
$data = $this->normalize($data, $format, $context);
}

Expand All @@ -124,7 +124,7 @@ final public function serialize($data, $format, array $context = array())
*/
final public function deserialize($data, $type, $format, array $context = array())
{
if (!$this->supportsDecoding($format)) {
if (!$this->supportsDecoding($format, $context)) {
throw new NotEncodableValueException(sprintf('Deserialization for the format %s is not supported', $format));
}

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.