$baseURL = DI::baseUrl()->get();
- $xml = null;
-
- XML::fromArray([
+ $xmlString = XML::fromArray([
'XRD' => [
'@attributes' => [
'xmlns' => 'http://docs.oasis-open.org/ns/xri/xrd-1.0',
]
],
],
- ], $xml);
+ ]);
- System::httpExit($xml->saveXML(), Response::TYPE_XML, 'application/xrd+xml');
+ System::httpExit($xmlString, Response::TYPE_XML, 'application/xrd+xml');
}
function oexchange_content(App $a)
}
DI::apiResponse()->setType(Response::TYPE_XML);
- DI::apiResponse()->addContent(XML::fromArray(["result" => $result], $xml));
+ DI::apiResponse()->addContent(XML::fromArray(['result' => $result]));
DI::page()->exit(DI::apiResponse()->generate());
self::exit();
$data3 = [$root_element => $data2];
- return XML::fromArray($data3, $xml, false, $namespaces);
+ return XML::fromArray($data3, $dummy, false, $namespaces);
}
/**
$baseUrl = DI::baseUrl()->get();
/** @var DOMDocument $xml */
- $xml = null;
-
XML::fromArray([
'OpenSearchDescription' => [
'@attributes' => [
{
protected function rawContent(array $request = [])
{
- $xml = null;
$content = XML::fromArray([
'rsd' => [
'@attributes' => [
],
],
],
- ], $xml);
+ ]);
System::httpExit($content, Response::TYPE_XML);
}
}
$domain = DI::baseUrl()->get();
- $xml = null;
XML::fromArray([
'XRD' => [
'@attributes' => [
{
$baseURL = $this->baseUrl->get();
- $xml = null;
-
- XML::fromArray([
+ $xmlString = XML::fromArray([
'XRD' => [
'@attributes' => [
'xmlns' => 'http://docs.oasis-open.org/ns/xri/xrd-1.0',
]
],
],
- ], $xml);
+ ]);
header('Access-Control-Allow-Origin: *');
- System::httpExit($xml->saveXML(), Response::TYPE_XML, 'application/xrd+xml');
+ System::httpExit($xmlString, Response::TYPE_XML, 'application/xrd+xml');
}
}
$namespaces = ['me' => ActivityNamespace::SALMON_ME];
- return XML::fromArray($xmldata, $xml, false, $namespaces);
+ return XML::fromArray($xmldata, $dummy, false, $namespaces);
}
/**
* @param array $message The message data
*
* @return string The post XML
+ * @throws \Exception
*/
public static function buildPostXml(string $type, array $message): string
{
- $data = [$type => $message];
-
- return XML::fromArray($data, $xml);
+ return XML::fromArray([$type => $message]);
}
/**
$namespaces = ['me' => ActivityNamespace::SALMON_ME];
- $salmon = XML::fromArray($xmldata, $xml, false, $namespaces);
+ $salmon = XML::fromArray($xmldata, $dummy, false, $namespaces);
// slap them
$postResult = DI::httpClient()->post($url, $salmon, [
]
];
- $namespaces = ['me' => ActivityNamespace::SALMON_ME];
-
- $salmon = XML::fromArray($xmldata, $xml, false, $namespaces);
+ $salmon = XML::fromArray($xmldata, $dummy, false, $namespaces);
// slap them
$postResult = DI::httpClient()->post($url, $salmon, [
]
];
- $namespaces = ['me' => ActivityNamespace::SALMON_ME];
-
- $salmon = XML::fromArray($xmldata, $xml, false, $namespaces);
+ $salmon = XML::fromArray($xmldata, $dummy, false, $namespaces);
// slap them
$postResult = DI::httpClient()->post($url, $salmon, [
/**
* Creates an XML structure out of a given array
*
- * @param array $array The array of the XML structure that will be generated
- * @param object $xml The created XML will be returned by reference
- * @param bool $remove_header Should the XML header be removed or not?
- * @param array $namespaces List of namespaces
- * @param bool $root interally used parameter. Mustn't be used from outside.
+ * @param array $array The array of the XML structure that will be generated
+ * @param object|null $xml The created XML will be returned by reference
+ * @param bool $remove_header Should the XML header be removed or not?
+ * @param array $namespaces List of namespaces
+ * @param bool $root interally used parameter. Mustn't be used from outside.
* @return string
+ * @throws \Exception
*/
- public static function fromArray(array $array, &$xml, bool $remove_header = false, array $namespaces = [], bool $root = true): string
+ public static function fromArray(array $array, object &$xml = null, bool $remove_header = false, array $namespaces = [], bool $root = true): string
{
if ($root) {
foreach ($array as $key => $value) {
if (!is_array($value)) {
$element = $xml->addChild($key, self::escape($value ?? ''), $namespace);
- } elseif (is_array($value)) {
+ } else {
$element = $xml->addChild($key, null, $namespace);
self::fromArray($value, $element, $remove_header, $namespaces, false);
}