Closed annavanbiemen closed 3 years ago
On second thought... automatically detecting the type of XML argument passed adds complexity while the caller can just simply use a single method call to the appropriate API to convert any SimpleXMLElement or DOMDocument instance into a string.
A string-only API should suffice:
public function xml(string $document): Response
Or register an xml handler like this:
$output->register(SimpleXMLElement::class, function (SimpleXMLElement $xml) use ($output): Response {
return $output->text($xml->asXML())->withContentType('text/xml');
});
An XML handler that set's the header would be an useful addition though.
Added the xml handler with just a text/xml Content-Type.
The Output class should be able to produce XML responses using either an