-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Allow to normalize \Traversable when serializing xml #17984
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ping @dunglas |
$serializer = new Serializer(array(new CustomNormalizer()), array('xml' => new XmlEncoder())); | ||
$this->encoder->setSerializer($serializer); | ||
|
||
$expected = '<?xml version="1.0"?>'."\n". |
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 use the heredoc syntax for clarity.
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.
done
👍 |
It should be tested but it looks like a good idea. |
Thank you @Ener-Getick. |
…-Getick) This PR was merged into the 2.3 branch. Discussion ---------- Allow to normalize \Traversable when serializing xml | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | no | Fixed tickets | | License | MIT It's impossible to normalize an object implementing ``\Traversable`` when using the ``XMLEncoder``. For example we can't customize the serializer output when serializing a ``FormInterface`` instance. So my proposition is to fix this by using the default XML encoder output only when the serializer can't normalize the data. Commits ------- 97c5d27 Allow to normalize \Traversable
@Ener-Getick I've merged this one as this is a bug fix. Feel free to open a new PR for the other change if it makes sense. |
This PR was merged into the 2.0 branch. Discussion ---------- Removes a hack Removes a hack as symfony/symfony#17984 has been merged. Commits ------- 7bcd70b Remove a hack
It's impossible to normalize an object implementing
\Traversable
when using theXMLEncoder
. For example we can't customize the serializer output when serializing aFormInterface
instance.So my proposition is to fix this by using the default XML encoder output only when the serializer can't normalize the data.