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 b03d370

Browse filesBrowse files
committed
feature #18036 [Serializer] XmlEncoder: Make load flags configurable (dunglas)
This PR was squashed before being merged into the 3.1-dev branch (closes #18036). Discussion ---------- [Serializer] XmlEncoder: Make load flags configurable | Q | A | ------------- | --- | Branch | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #17987 | License | MIT | Doc PR | todo Commits ------- 0826068 [Serializer] XmlEncoder: Make load flags configurable
2 parents 8acc601 + 0826068 commit b03d370
Copy full SHA for b03d370

File tree

Expand file treeCollapse file tree

1 file changed

+6
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-3
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Encoder/XmlEncoder.php
+6-3Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.