Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[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

Closed

Conversation

@amoiraud
Copy link
Contributor

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#20398
LicenseMIT
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 :

    <node>         <subnode>Value</subnode>         <emptysubnode/>    </node>

To this :

    <node>         <subnode>Value</subnode>    </node>

$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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

should beelseif

Copy link
Member

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

Copy link
ContributorAuthor

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);}

$expected ='<?xml version="1.0"?>'."\n".
'<response><person><firstname>Peter</firstname></person></response>'."\n";

$context =array(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can be inline

Copy link
ContributorAuthor

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
Copy link
Member

👍

@dunglas
Copy link
Member

Can you open a doc PR please@amoiraud

@nicolas-grekasnicolas-grekas added this to the3.x milestoneDec 6, 2016
@dunglas
Copy link
Member

Thank you@amoiraud.

@dunglasdunglas closed thisDec 6, 2016
dunglas added a commit that referenced this pull requestDec 6, 2016
…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
Copy link
ContributorAuthor

Hi@dunglas
I'm OK to open a doc PR but can you tell me where should I write this documentation ?
Because in the actual documentation I haven't found any mention of the $context param
Thanks

@dunglas
Copy link
Member

dunglas commentedDec 7, 2016
edited
Loading

@amoiraud, I suggest to add a new section about theXmlEncoder inhttps://github.com/symfony/symfony-docs/blob/master/components/serializer.rst and list its available options.

amoiraud reacted with thumbs up emoji

@nicolas-grekasnicolas-grekas modified the milestones:3.x,3.3Mar 24, 2017
@fabpotfabpot mentioned this pull requestMay 1, 2017
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull requestJan 5, 2018
… 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
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@dunglasdunglasdunglas left review comments

@xabbuhxabbuhxabbuh approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

5 participants

@amoiraud@dunglas@xabbuh@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp