8000 add context to serialize and deserialize · symfony/symfony@6f8d5e2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6f8d5e2

Browse files
andrey1snicolas-grekas
andrey1s
authored andcommitted
add context to serialize and deserialize
1 parent d7b98f9 commit 6f8d5e2

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Symfony/Component/Serializer/CHANGELOG.md

Lines 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

Lines 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