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

Breadcrumb

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

function XmlFileLoader::shouldEnableEntityLoader

1 call to XmlFileLoader::shouldEnableEntityLoader()
XmlFileLoader::validateSchema in vendor/symfony/dependency-injection/Loader/XmlFileLoader.php
Validates a documents XML schema.

File

vendor/symfony/dependency-injection/Loader/XmlFileLoader.php, line 798

Class

XmlFileLoader
XmlFileLoader loads XML files service definitions.

Namespace

Symfony\Component\DependencyInjection\Loader

Code

private function shouldEnableEntityLoader() : bool {
    static $dom, $schema;
    if (null === $dom) {
        $dom = new \DOMDocument();
        $dom->loadXML('<?xml version="1.0"?><test/>');
        $tmpfile = tempnam(sys_get_temp_dir(), 'symfony');
        register_shutdown_function(static function () use ($tmpfile) {
            @unlink($tmpfile);
        });
        $schema = '<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:include schemaLocation="file:///' . rawurlencode(str_replace('\\', '/', $tmpfile)) . '" />
</xsd:schema>';
        file_put_contents($tmpfile, '<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="test" type="testType" />
  <xsd:complexType name="testType"/>
</xsd:schema>');
    }
    return !@$dom->schemaValidateSource($schema);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal