Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ScopeFallbackResolver.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Store\Model;
7 
10 
12 {
16  protected $storeManager;
17 
21  protected $fallback = [];
22 
26  public function __construct(
28  ) {
29  $this->storeManager = $storeManager;
30  }
31 
35  public function getFallbackScope($scope, $scopeId, $forConfig = true)
36  {
37  if (!isset($this->fallback[$scope][$scopeId][$forConfig])) {
38  $fallback = [null, null];
39  switch ($scope) {
43  break;
45  $fallback = [
47  $this->storeManager->getGroup($scopeId)->getWebsiteId()
48  ];
49  break;
52  $fallback = $forConfig
53  ? [ScopeInterface::SCOPE_WEBSITES, $this->storeManager->getStore($scopeId)->getWebsiteId()]
54  : [ScopeInterface::SCOPE_GROUP, $this->storeManager->getStore($scopeId)->getStoreGroupId()];
55  }
56  $this->fallback[$scope][$scopeId][$forConfig] = $fallback;
57  }
58  return $this->fallback[$scope][$scopeId][$forConfig];
59  }
60 }
getFallbackScope($scope, $scopeId, $forConfig=true)
__construct(StoreManagerInterface $storeManager)