-
-
Notifications
You must be signed in to change notification settings - Fork 309
Add an XmlAttributeMap #164
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
Did you check @XmlKeyValuePairs? After a quick look, it looks like what you are proposing. |
Just checked it, it doesnt produce the expected XML. I'm using this class: <?php
/**
* @Serializer\XmlRoot("input")
*/
class Input
{
/**
* @Serializer\XmlAttributeMap
*/
public $attributes = array(
'type' => 'integer',
'value' => '1',
'name' => 'search[page]',
);
} With <input>
<attributes>
<type>
<![CDATA[integer]]>
</type>
<value>
<![CDATA[1]]>
</value>
<name>
<![CDATA[search[page]]]>
</name>
</attributes>
</input> Whereas with <input type="integer" value="1" name="search[page]"/> |
@schmittjoh ? Is there something missing in my implementation, tests ? |
Looks good, could you rebase this on latest master? It should only require a minor update in the base test case. |
Rebase on master done |
@@ -180,6 +180,23 @@ public function visitProperty(PropertyMetadata $metadata, $object) | |||
return; | |||
} | |||
|
|||
if ($metadata->xmlAttributeMap) { | |||
if (!is_array($v) && !$v instanceof \Traversable) { |
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.
Did you add the Traversable check here?
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.
Huh ? !$v instanceof \Traversable
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.
Just asking because I've removed the special handling for traversables in the master branch. However, in that case we can probably keep it.
Could you add an extra test case to avoid regressions?
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.
I'm going to remove the Traversable handling, because YamlSerializationVisitor::75
uses array_keys
. On a Traversable object it fails.
@schmittjoh I removed the Traversable handling, and added a test in |
Thanks, merged! |
Hi,
I needed this, so I share it.
I'm not sure if the results i'm expecting for the json and yaml formats are right.
In the tests i expect:
But should it be
Any feedback is welcome.