#24046 added check for ext-dom to XmlUtil::loadFile

This commit is contained in:
Oleg Andreyev 2017-08-31 12:18:43 +03:00 committed by Maxime Steinhausser
parent 9c796b4e39
commit 2f292c247e

View File

@ -37,9 +37,14 @@ class XmlUtils
* @return \DOMDocument
*
* @throws \InvalidArgumentException When loading of XML file returns error
* @throws \RuntimeException When DOM extension is missing
*/
public static function loadFile($file, $schemaOrCallable = null)
{
if (!extension_loaded('dom')) {
throw new \RuntimeException('Extension DOM is required.');
}
$content = @file_get_contents($file);
if ('' === trim($content)) {
throw new \InvalidArgumentException(sprintf('File %s does not contain valid XML, it is empty.', $file));