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\LoaderCode
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);
}