Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Serializer] XmlEncoder doesn't ignore PI nodes while encoding#27926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
dunglas commentedJul 11, 2018
We follow the robustness principle "Be conservative in what you send, be liberal in what you accept", so while it's ok to ignore I suggest to add a new constructor parameter: publicfunction __construct(string$rootNodeName ='response',int$loadOptions =null,array$decoderIgnoredNodeTypes =array(XML_PI_NODE,XML_COMMENT_NODE),array$encoderIgnoredNodeTypes =array()) |
d3d136d to9c182a2Comparemaidmaid commentedAug 6, 2018
I followed your suggestion@dunglas, could you review ? |
nicolas-grekas commentedAug 24, 2018
Is the "BC break" label still valid? If not can you please update the PR description? Rebase needed btw. |
maidmaid commentedAug 24, 2018
@nicolas-grekas Done :) |
dunglas commentedAug 25, 2018
Thank you@maidmaid. |
…encoding (maidmaid)This PR was merged into the 4.2-dev branch.Discussion----------[Serializer] XmlEncoder doesn't ignore PI nodes while encoding| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | no| Fixed tickets | /| License | MIT| Doc PR | /It's sometimes important to get only the XML body without the processing instructions (like the `<?xml version="1.0" ?>` on the top of your XML doc). At the moment, it's possible to ignore them while decoding, but not while encoding.```php$encoder = new XmlEncoder('response', null, $ignoredNodeTypes = [XML_PI_NODE]);echo $encoder->encode([], 'xml');``````Expected:<response/>Actual:<?xml version="1.0"?><response/>```So, a new `$encoderIgnoredNodeTypes` arg is added to the constructor which will be:```phppublic function __construct(string $rootNodeName = 'response', int $loadOptions = null, array $decoderIgnoredNodeTypes = array(XML_PI_NODE, XML_COMMENT_NODE), array $encoderIgnoredNodeTypes = array())```Commits-------2223fcc Allow to ignore PI while encoding…redNodeTypes arg in XmlEncoder contrustor (maidmaid)This PR was merged into the 4.2-dev branch.Discussion----------[Serializer] Update changelog about the new $encoderIgnoredNodeTypes arg in XmlEncoder contrustor| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#27926| License | MIT| Doc PR | /Commits-------49f3bfc Update changelog
…ML encoding (maidmaid)This PR was merged into the 4.2-dev branch.Discussion----------[Serializer] Add support for ignoring comments while XML encoding| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | /| License | MIT| Doc PR | /In addition to#27926 which allowed to ignore XML processing instructions, this PR allows to ignore the XML comments while encoding.Commits-------8f8230a Add support for ignoring comments while XML encoding
javiereguiluz commentedSep 7, 2018
I've createdsymfony/symfony-docs#10286 to document this new feature. Please, don't forget to create a doc issue for every new feature. |
Uh oh!
There was an error while loading.Please reload this page.
It's sometimes important to get only the XML body without the processing instructions (like the
<?xml version="1.0" ?>on the top of your XML doc). At the moment, it's possible to ignore them while decoding, but not while encoding.So, a new
$encoderIgnoredNodeTypesarg is added to the constructor which will be: