/** * 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 === null) { $class = $this->_domDocumentClass; $domDocument = new $class($file, [], null, $this->_schemaFile); } else { $domDocument->merge($file); } } catch (\Magento\Framework\Config\Dom\ValidationException $e) { throw new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase("Invalid XML in file %1:\n%2", [$file, $e->getMessage()])); } } $output = []; if ($domDocument) { $output = $this->_converter->convert($domDocument->getDom()); } return $output; }
/** * Read configuration files * * @param array $fileList * @return array * @throws \Magento\Framework\Exception\LocalizedException */ protected function _readFiles($fileList) { /** @var \Magento\Framework\Config\Dom $configMerger */ $configMerger = null; foreach ($fileList as $key => $content) { try { if (!$configMerger) { $configMerger = $this->_createConfigMerger($this->_domDocumentClass, $content); } else { $configMerger->merge($content); } } catch (\Magento\Framework\Config\Dom\ValidationException $e) { throw new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase("Invalid XML in file %1:\n%2", [$key, $e->getMessage()])); } } if ($this->_isValidated) { $errors = []; if ($configMerger && !$configMerger->validate($this->_schemaFile, $errors)) { $message = "Invalid Document \n"; throw new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase($message . implode("\n", $errors))); } } $output = []; if ($configMerger) { $output = $this->_converter->convert($configMerger->getDom()); } return $output; }
/** * Load configuration scope * * @param string|null $scope * @return array * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function read($scope = null) { return $this->converter->convert($this->domMerger->getDom()); }