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 94675e1

Browse filesBrowse files
bug #26043 [Serialized] add context to serialize and deserialize (andrey1s)
This PR was merged into the 3.4 branch. Discussion ---------- [Serialized] add context to serialize and deserialize | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | Tests pass? | yes | License | MIT added context to `supportsDecoding` `needsNormalization` and `supportsEncoding` Commits ------- 6f8d5e2 add context to serialize and deserialize
2 parents d7b98f9 + 6f8d5e2 commit 94675e1
Copy full SHA for 94675e1

File tree

2 files changed

+4
-3
lines changed
Filter options

2 files changed

+4
-3
lines changed

‎src/Symfony/Component/Serializer/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CHANGELOG
1010
* added getter for extra attributes in `ExtraAttributesException`
1111
* improved `CsvEncoder` to handle variable nested structures
1212
* CSV headers can be passed to the `CsvEncoder` via the `csv_headers` serialization context variable
13+
* added `$context` when checking for encoding, decoding and normalizing in `Serializer`
1314

1415
3.3.0
1516
-----

‎src/Symfony/Component/Serializer/Serializer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Serializer.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ public function __construct(array $normalizers = array(), array $encoders = arra
108108
*/
109109
final public function serialize($data, $format, array $context = array())
110110
{
111-
if (!$this->supportsEncoding($format)) {
111+
if (!$this->supportsEncoding($format, $context)) {
112112
throw new NotEncodableValueException(sprintf('Serialization for the format %s is not supported', $format));
113113
}
114114

115-
if ($this->encoder->needsNormalization($format)) {
115+
if ($this->encoder->needsNormalization($format, $context)) {
116116
$data = $this->normalize($data, $format, $context);
117117
}
118118

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

0 commit comments

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