File tree 2 files changed +17
-3
lines changed
src/Symfony/Component/Serializer
2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -488,6 +488,9 @@ private function selectNodeType(\DOMNode $node, $val)
488
488
$ node ->appendChild ($ child );
489
489
} elseif ($ val instanceof \Traversable) {
490
490
$ this ->buildXml ($ node , $ val );
491
+ } elseif ($ val instanceof \DOMNode) {
492
+ $ child = $ this ->dom ->importNode ($ val , true );
493
+ $ node ->appendChild ($ child );
491
494
} elseif (\is_object ($ val )) {
492
495
if (null === $ this ->serializer ) {
493
496
throw new BadMethodCallException (sprintf ('The serializer needs to be set to allow "%s()" to be used with object data. ' , __METHOD__ ));
<
8000
div aria-hidden="true" style="left:-2px" class="position-absolute top-0 d-flex user-select-none DiffLineTableCellParts-module__in-progress-comment-indicator--hx3m3">@@ -502,9 +505,6 @@ private function selectNodeType(\DOMNode $node, $val)
502
505
return $ this ->appendText ($ node , $ val );
503
506
} elseif (\is_bool ($ val )) {
504
507
return $ this ->appendText ($ node , (int ) $ val );
505
- } elseif ($ val instanceof \DOMNode) {
506
- $ child = $ this ->dom ->importNode ($ val , true );
507
- $ node ->appendChild ($ child );
508
508
}
509
509
510
510
return true ;
Original file line number Diff line number Diff line change @@ -662,6 +662,20 @@ public function testEncodeXmlWithBoolValue()
662
662
$ this ->assertEquals ($ expectedXml , $ actualXml );
663
663
}
664
664
665
+ public function testEncodeXmlWithDomNodeValue ()
666
+ {
667
+ $ expectedXml = <<<'XML'
668
+ <?xml version="1.0"?>
669
+ <response><foo>bar</foo><bar>foo & bar</bar></response>
670
+
671
+ XML;
672
+ $ document = new \DOMDocument ();
673
+
674
+ $ actualXml = $ this ->encoder ->encode (['foo ' => $ document ->createTextNode ('bar ' ), 'bar ' => $ document ->createTextNode ('foo & bar ' )], 'xml ' );
675
+
676
+ $ this ->assertEquals ($ expectedXml , $ actualXml );
677
+ }
678
+
665
679
public function testEncodeXmlWithDateTimeObjectValue ()
666
680
{
667
681
$ xmlEncoder = $ this ->createXmlEncoderWithDateTimeNormalizer ();
You can’t perform that action at this time.
0 commit comments