Third party package support: Could not create XML from array
dzandrey opened this issue · 3 comments
dzandrey commented
Could you add support for redmine tags - https://www.redmine.org/plugins/redmineup_tags
In my example, I am passing an array
Redmine::issue()->create(
// ...
'tag_list' => [
'approved',
'finished',
],
);
But I get an error
Redmine \ Exception \ SerializerException
Could not create XML from array: ""
I added a fix to this PR - #379, but it was rejected.
Art4 commented
I cannot find any REST API documentation for this tags plugin, but if I understand your issue and #379 correctly you would like to have general array support in XmlSerializer class to make something like this possible:
$serializer = XmlSerializer::createFromArray([
'issue' => [
'tag_list' => [
'approved',
'finished',
],
],
]);
var_dump($serializer->__toString());
The generated XML should then look like this:
<?xml version="1.0"?>
<issue>
<tag_list type="array">
<tag_list>approved</tag_list>
<tag_list>finished</tag_list>
</tag_list>
</issue>
Is this correct?
dzandrey commented
Yes.
SimpleXMLElement Object
(
[tag_list] => SimpleXMLElement Object
(
[@attributes] => Array
(
[type] => array
)
[tag_list] => Array
(
[0] => approved
[1] => finished
)
)
)