You are here

private function XmlEncoder::createDomDocument in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/serializer/Encoder/XmlEncoder.php \Symfony\Component\Serializer\Encoder\XmlEncoder::createDomDocument()

Create a DOM document, taking serializer options into account.

Parameters

array $context options that the encoder has access to.:

Return value

\DOMDocument

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 513

Class

XmlEncoder
Encodes XML data.

Namespace

Symfony\Component\Serializer\Encoder

Code

private function createDomDocument(array $context) {
  $document = new \DOMDocument();

  // Set an attribute on the DOM document specifying, as part of the XML declaration,
  $xmlOptions = array(
    // nicely formats output with indentation and extra space
    'xml_format_output' => 'formatOutput',
    // the version number of the document
    'xml_version' => 'xmlVersion',
    // the encoding of the document
    'xml_encoding' => 'encoding',
    // whether the document is standalone
    'xml_standalone' => 'xmlStandalone',
  );
  foreach ($xmlOptions as $xmlOption => $documentProperty) {
    if (isset($context[$xmlOption])) {
      $document->{$documentProperty} = $context[$xmlOption];
    }
  }
  return $document;
}