8000 [Serializer] XmlEncoder: Make load flags configurable · symfony/symfony@0826068 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0826068

Browse files
dunglasfabpot
authored andcommitted
[Serializer] XmlEncoder: Make load flags configurable
1 parent b868feb commit 0826068

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Symfony/Component/Serializer/Encoder/XmlEncoder.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,18 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec
3030
private $format;
3131
private $context;
3232
private $rootNodeName = 'response';
33+
private $loadOptions;
3334

3435
/**
3536
* Construct new XmlEncoder and allow to change the root node element name.
3637
*
37-
* @param string $rootNodeName
38+
* @param string $rootNodeName
39+
* @param int|null $loadOptions A bit field of LIBXML_* constants
3840
*/
39-
public function __construct($rootNodeName = 'response')
41+
public function __construct($rootNodeName = 'response', $loadOptions = null)
4042
{
4143
$this->rootNodeName = $rootNodeName;
44+
$this->loadOptions = null !== $loadOptions ? $loadOptions : LIBXML_NONET | LIBXML_NOBLANKS;
4245
}
4346

4447
/**
@@ -81,7 +84,7 @@ public function decode($data, $format, array $context = array())
8184
libxml_clear_errors();
8285

8386
$dom = new \DOMDocument();
84-
$dom->loadXML($data, LIBXML_NONET | LIBXML_NOBLANKS);
87+
$dom->loadXML($data, $this->loadOptions);
8588

8689
libxml_use_internal_errors($internalErrors);
8790
libxml_disable_entity_loader($disableEntities);

0 commit comments

Comments
 (0)
0