_schemaFile = $schemaLocator->getSchema(); $this->_fileResolver = $fileResolver; $this->_converter = $converter; $this->domFactory = $domFactory; $this->_fileName = $fileName; } /** * Read configuration scope * * @return array * * @throws \Magento\Framework\Exception\LocalizedException */ public function read() { $fileList = []; foreach ($this->_scopePriorityScheme as $scope) { $directories = $this->_fileResolver->get($this->_fileName, $scope); foreach ($directories as $key => $directory) { $fileList[$key] = $directory; } } if (!count($fileList)) { return []; } /** @var \Magento\Framework\Config\Dom $domDocument */ $domDocument = null; foreach ($fileList as $file) { try { if (!$domDocument) { $domDocument = $this->domFactory->createDom(['xml' => $file, 'schemaFile' => $this->_schemaFile]); } else { $domDocument->merge($file); } } catch (\Magento\Framework\Config\Dom\ValidationException $e) { throw new \Magento\Framework\Exception\LocalizedException( new \Magento\Framework\Phrase( 'The XML in file "%1" is invalid:' . "\n%2\nVerify the XML and try again.", [$file, $e->getMessage()] ) ); } } $output = []; if ($domDocument) { $output = $this->_converter->convert($domDocument->getDom()); } return $output; } }