Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
StoreConfigurationProvider.php
Go to the documentation of this file.
1 <?php
8 
14 
19 {
23  private $scopeConfig;
24 
28  private $configPaths;
29 
33  private $storeManager;
34 
40  public function __construct(
41  ScopeConfigInterface $scopeConfig,
42  StoreManagerInterface $storeManager,
43  array $configPaths
44  ) {
45  $this->scopeConfig = $scopeConfig;
46  $this->configPaths = $configPaths;
47  $this->storeManager = $storeManager;
48  }
49 
55  public function getReport()
56  {
57  $configReport = $this->generateReportForScope(ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 0);
58 
60  foreach ($this->storeManager->getWebsites() as $website) {
61  $configReport = array_merge(
62  $this->generateReportForScope(ScopeInterface::SCOPE_WEBSITES, $website->getId()),
63  $configReport
64  );
65  }
66 
68  foreach ($this->storeManager->getStores() as $store) {
69  $configReport = array_merge(
70  $this->generateReportForScope(ScopeInterface::SCOPE_STORES, $store->getId()),
71  $configReport
72  );
73  }
74  return new \IteratorIterator(new \ArrayIterator($configReport));
75  }
76 
84  private function generateReportForScope($scope, $scopeId)
85  {
86  $report = [];
87  foreach ($this->configPaths as $configPath) {
88  $report[] = [
89  "config_path" => $configPath,
90  "scope" => $scope,
91  "scope_id" => $scopeId,
92  "value" => $this->scopeConfig->getValue(
93  $configPath,
94  $scope,
95  $scopeId
96  )
97  ];
98  }
99  return $report;
100  }
101 }
$storeManager
__construct(ScopeConfigInterface $scopeConfig, StoreManagerInterface $storeManager, array $configPaths)