function XmlEncoder::createDomDocument
Create a DOM document, taking serializer options into account.
1 call to XmlEncoder::createDomDocument()
- XmlEncoder::encode in vendor/
symfony/ serializer/ Encoder/ XmlEncoder.php - Encodes data into the given format.
File
-
vendor/
symfony/ serializer/ Encoder/ XmlEncoder.php, line 479
Class
- XmlEncoder
- @author Jordi Boggiano <j.boggiano@seld.be> @author John Wards <jwards@whiteoctober.co.uk> @author Fabian Vogler <fabian@equivalence.ch> @author Kévin Dunglas <dunglas@gmail.com> @author Dany Maillard…
Namespace
Symfony\Component\Serializer\EncoderCode
private function createDomDocument(array $context) : \DOMDocument {
$document = new \DOMDocument();
// Set an attribute on the DOM document specifying, as part of the XML declaration,
$xmlOptions = [
// nicely formats output with indentation and extra space
self::FORMAT_OUTPUT => 'formatOutput',
// the version number of the document
self::VERSION => 'xmlVersion',
// the encoding of the document
self::ENCODING => 'encoding',
// whether the document is standalone
self::STANDALONE => 'xmlStandalone',
];
foreach ($xmlOptions as $xmlOption => $documentProperty) {
if ($contextOption = $context[$xmlOption] ?? $this->defaultContext[$xmlOption] ?? false) {
$document->{$documentProperty} = $contextOption;
}
}
return $document;
}