Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. XmlEncoder.php

function XmlEncoder::saveXml

Throws

NotEncodableValueException

1 call to XmlEncoder::saveXml()
XmlEncoder::encode in vendor/symfony/serializer/Encoder/XmlEncoder.php
Encodes data into the given format.

File

vendor/symfony/serializer/Encoder/XmlEncoder.php, line 506

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\Encoder

Code

private function saveXml(\DOMDocument $document, ?\DOMNode $node = null, ?int $options = null) : string {
    $prevErrorHandler = set_error_handler(static function ($type, $message, $file, $line, $context = []) use (&$prevErrorHandler) {
        if (\E_ERROR === $type || \E_WARNING === $type) {
            throw new NotEncodableValueException($message);
        }
        return $prevErrorHandler ? $prevErrorHandler($type, $message, $file, $line, $context) : false;
    });
    try {
        return $document->saveXML($node, $options);
    } finally {
        restore_error_handler();
    }
}
RSS feed
Powered by Drupal