@@ -24,6 +24,7 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec
24
24
{
25
25
private $ dom ;
26
26
private $ format ;
27
+ private $ context ;
27
28
private $ rootNodeName = 'response ' ;
28
29
29
30
/**
@@ -49,6 +50,7 @@ public function encode($data, $format, array $context = array())
49
50
50
51
$ this ->dom = new \DOMDocument ();
51
52
$ this ->format = $ format ;
53
+ $ this ->context = $ context ;
52
54
53
55
if (null !== $ data && !is_scalar ($ data )) {
54
56
$ root = $ this ->dom ->createElement ($ xmlRootNodeName );
@@ -325,7 +327,7 @@ private function buildXml($parentNode, $data, $xmlRootNodeName = null)
325
327
}
326
328
327
329
if (is_object ($ data )) {
328
- $ data = $ this ->serializer ->normalize ($ data , $ this ->format );
330
+ $ data = $ this ->serializer ->normalize ($ data , $ this ->format , $ this -> context );
329
331
if (null !== $ data && !is_scalar ($ data )) {
330
332
return $ this ->buildXml ($ parentNode , $ data , $ xmlRootNodeName );
331
333
}
@@ -399,7 +401,7 @@ private function selectNodeType($node, $val)
399
401
} elseif ($ val instanceof \Traversable) {
400
402
$ this ->buildXml ($ node , $ val );
401
403
} elseif (is_object ($ val )) {
402
- return $ this ->buildXml ($ node , $ this ->serializer ->normalize ($ val , $ this ->format ));
404
+ return $ this ->buildXml ($ node , $ this ->serializer ->normalize ($ val , $ this ->format , $ this -> context ));
403
405
} elseif (is_numeric ($ val )) {
404
406
return $ this ->appendText ($ node , (string ) $ val );
405
407
} elseif (is_string ($ val ) && $ this ->needsCdataWrapping ($ val )) {
0 commit comments