Created
June 30, 2017 14:16
-
-
Save szeidler/76533a3fb6684eadcd847227a0739998 to your computer and use it in GitHub Desktop.
Add support for index values on xml output. Otherwise you will lose information about numeric array keys.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/servers/rest_server/includes/ServicesFormatter.inc b/servers/rest_server/includes/ServicesFormatter.inc | |
index 9799b19..8ce275a 100644 | |
--- a/servers/rest_server/includes/ServicesFormatter.inc | |
+++ b/servers/rest_server/includes/ServicesFormatter.inc | |
@@ -61,6 +61,7 @@ class ServicesXMLFormatter implements ServicesFormatterInterface { | |
$assoc = FALSE || empty($data); | |
foreach ($data as $key => $value) { | |
if (is_numeric($key)) { | |
+ $id = $key; | |
$key = 'item'; | |
} | |
else { | |
@@ -69,6 +70,9 @@ class ServicesXMLFormatter implements ServicesFormatterInterface { | |
$key = preg_replace('/^([0-9]+)/', '_$1', $key); | |
} | |
$element = $doc->createElement($key); | |
+ if (isset($id)) { | |
+ $element->setAttribute('id', $id); | |
+ } | |
$parent->appendChild($element); | |
$this->xml_recursive($doc, $element, $value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment