Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Reader.php
Go to the documentation of this file.
1 <?php
7 
9 
15 class Reader implements \Magento\Framework\App\Config\Scope\ReaderInterface
16 {
20  private $sources;
21 
25  public function __construct(array $sources)
26  {
27  $this->sources = $this->prepareSources($sources);
28  }
29 
37  public function read($scope = null)
38  {
39  $config = [];
40  foreach ($this->sources as $sourceData) {
42  $source = $sourceData['class'];
43  $config = array_replace_recursive($config, $source->get($scope));
44  }
45 
46  return $config;
47  }
48 
55  private function prepareSources(array $array)
56  {
57  $array = array_filter(
58  $array,
59  function ($item) {
60  return (!isset($item['disable']) || !$item['disable']) && $item['class'];
61  }
62  );
63  uasort(
64  $array,
65  function ($firstItem, $nexItem) {
66  return (int)$firstItem['sortOrder'] <=> (int)$nexItem['sortOrder'];
67  }
68  );
69 
70  return $array;
71  }
72 }
$config
Definition: fraud_order.php:17
$source
Definition: source.php:23
__construct(array $sources)
Definition: Reader.php:25