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] Allow removing empty tags in generated XML#20524
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
| $append =$this->appendNode($parentNode,$data,'item',$key); | ||
| }else { | ||
| $append =$this->appendNode($parentNode,$data,$key); | ||
| if ($data !==null || !isset($this->context['remove_empty_tags']) ||$this->context['remove_empty_tags'] ===false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
should beelseif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
and please also use a Yoda condition here:null !== $data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It's done :
}elseif (null !==$data || !isset($this->context['remove_empty_tags']) ||false ===$this->context['remove_empty_tags']) {$append =$this->appendNode($parentNode,$data,$key);}
Use Yoda conditions
| $expected ='<?xml version="1.0"?>'."\n". | ||
| '<response><person><firstname>Peter</firstname></person></response>'."\n"; | ||
| $context =array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Can be inline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
You're right i have made the modification
dunglas commentedNov 15, 2016
👍 |
dunglas commentedDec 6, 2016
Can you open a doc PR please@amoiraud |
dunglas commentedDec 6, 2016
Thank you@amoiraud. |
…generated XML (amoiraud)This PR was squashed before being merged into the 3.3-dev branch (closes#20524).Discussion----------[Serializer][XmlEncoder] Allow removing empty tags in generated XML| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#20398| License | MIT| Doc PR | ~Allow a new option in $context of XmlEncoder.php to remove empty tags if $context['remove_empty_tags'] setted to true, changing this :```xml <node> <subnode>Value</subnode> <emptysubnode/> </node>```To this :```xml <node> <subnode>Value</subnode> </node>```Commits-------0cb4d8e [Serializer][XmlEncoder] Allow removing empty tags in generated XML
amoiraud commentedDec 6, 2016
Hi@dunglas |
dunglas commentedDec 7, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@amoiraud, I suggest to add a new section about the |
… javiereguiluz)This PR was submitted for the master branch but it was merged into the 3.3 branch instead (closes#7231).Discussion----------Add documentation for XmlEncoder context paramAdd documentation for XmlEncoder context paramRelated to :symfony/symfony#20524Thisfixes#7227Commits-------5e23045 Minor tweaksadbc7b2 Minor rewords2dc6ed3 Minor syntax issue6050370 Minor syntax issues and some rewordings2f3cf02 Correcting my bad english with a bilingual friend60c7657 Add XmlEncoder documentation with $context available options04af434 erratumc83e59d Add XmlEncoder documentation with $context available options
Allow a new option in $context of XmlEncoder.php to remove empty tags if $context['remove_empty_tags'] setted to true, changing this :
To this :