Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Definition.php
Go to the documentation of this file.
1 <?php
8 
13 
17 class Definition extends \Magento\Framework\Config\Reader\Filesystem implements ReaderInterface
18 {
25  public function read($scope = null)
26  {
27  $scope = $scope ?: $this->_defaultScope;
28  $fileList = $this->_fileResolver->get($this->_fileName, $scope);
29  if (!count($fileList)) {
30  return [];
31  }
32  $output = $this->readFiles($fileList);
33 
34  return $output;
35  }
36 
44  private function readFiles($fileList)
45  {
47  $configMerger = null;
48  foreach ($fileList as $key => $content) {
49  try {
50  if (!$configMerger) {
51  $configMerger = $this->_createConfigMerger($this->_domDocumentClass, $content);
52  } else {
53  $configMerger->merge($content);
54  }
55  } catch (ValidationException $e) {
56  throw new LocalizedException(
57  new Phrase(
58  'The XML in file "%1" is invalid.' . "\n%2\nVerify the XML and try again.",
59  [$key, $e->getMessage()]
60  )
61  );
62  }
63  }
64  if ($this->validationState->isValidationRequired()) {
65  $errors = [];
66  if ($configMerger && !$configMerger->validate($this->_schemaFile, $errors)) {
67  $message = "Invalid Document \n";
68  throw new LocalizedException(
69  new Phrase($message . implode("\n", $errors))
70  );
71  }
72  }
73 
74  $output = [];
75  if ($configMerger) {
76  $output = $this->_converter->convert($configMerger->getDom()->documentElement);
77  }
78  return $output;
79  }
80 }
$fileList
Definition: export.php:13
$message
_createConfigMerger($mergerClass, $initialContents)
Definition: Filesystem.php:189
$errors
Definition: overview.phtml:9