mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Allow stdClass in XML responses
Signed-off-by: jld3103 <jld3103yt@gmail.com>
This commit is contained in:
parent
39b716cc78
commit
7f4651637a
2 changed files with 6 additions and 1 deletions
|
|
@ -143,6 +143,10 @@ abstract class BaseResponse extends Response {
|
|||
$k = 'element';
|
||||
}
|
||||
|
||||
if ($v instanceof \stdClass) {
|
||||
$v = [];
|
||||
}
|
||||
|
||||
if (\is_array($v)) {
|
||||
$writer->startElement($k);
|
||||
$this->toXML($v, $writer);
|
||||
|
|
|
|||
|
|
@ -45,13 +45,14 @@ class BaseResponseTest extends \Test\TestCase {
|
|||
'someElement' => 'withAttribute',
|
||||
],
|
||||
'value without key',
|
||||
'object' => new \stdClass(),
|
||||
];
|
||||
|
||||
$this->invokePrivate($response, 'toXml', [$data, $writer]);
|
||||
$writer->endDocument();
|
||||
|
||||
$this->assertEquals(
|
||||
"<?xml version=\"1.0\"?>\n<hello>hello</hello><information test=\"some data\"><someElement>withAttribute</someElement></information><element>value without key</element>\n",
|
||||
"<?xml version=\"1.0\"?>\n<hello>hello</hello><information test=\"some data\"><someElement>withAttribute</someElement></information><element>value without key</element><object/>\n",
|
||||
$writer->outputMemory(true)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue