コード例 #1
1
ファイル: Store.php プロジェクト: aiesh/magento2
 /**
  * Read configuration by code
  *
  * @param string $code
  * @return array
  */
 public function read($code = null)
 {
     if ($this->_appState->isInstalled()) {
         if (empty($code)) {
             $store = $this->_storeManager->getStore();
         } elseif ($code == \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT) {
             $store = $this->_storeManager->getDefaultStoreView();
         } else {
             $store = $this->_storeFactory->create();
             $store->load($code);
         }
         if (!$store->getCode()) {
             throw NoSuchEntityException::singleField('storeCode', $code);
         }
         $websiteConfig = $this->_scopePool->getScope(\Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE, $store->getWebsite()->getCode())->getSource();
         $config = array_replace_recursive($websiteConfig, $this->_initialConfig->getData("stores|{$code}"));
         $collection = $this->_collectionFactory->create(array('scope' => \Magento\Store\Model\ScopeInterface::SCOPE_STORES, 'scopeId' => $store->getId()));
         $dbStoreConfig = array();
         foreach ($collection as $item) {
             $dbStoreConfig[$item->getPath()] = $item->getValue();
         }
         $config = $this->_converter->convert($dbStoreConfig, $config);
     } else {
         $websiteConfig = $this->_scopePool->getScope(\Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE, \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT)->getSource();
         $config = $this->_converter->convert($websiteConfig, $this->_initialConfig->getData("stores|{$code}"));
     }
     return $config;
 }
コード例 #2
0
 /**
  * Read configuration data
  *
  * @return array
  */
 public function read()
 {
     $config = $this->_initialConfig->getData(\Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT);
     $collection = $this->_collectionFactory->create(['scope' => \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT]);
     $dbDefaultConfig = [];
     foreach ($collection as $item) {
         $dbDefaultConfig[$item->getPath()] = $item->getValue();
     }
     $dbDefaultConfig = $this->_converter->convert($dbDefaultConfig);
     $config = array_replace_recursive($config, $dbDefaultConfig);
     return $config;
 }
コード例 #3
0
ファイル: Website.php プロジェクト: opexsw/magento2
 /**
  * Read configuration by code
  *
  * @param string $code
  * @return array
  */
 public function read($code = null)
 {
     $config = array_replace_recursive($this->_scopePool->getScope(ScopeConfigInterface::SCOPE_TYPE_DEFAULT)->getSource(), $this->_initialConfig->getData("websites|{$code}"));
     $website = $this->_websiteFactory->create();
     $website->load($code);
     $collection = $this->_collectionFactory->create(['scope' => \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITES, 'scopeId' => $website->getId()]);
     $dbWebsiteConfig = [];
     foreach ($collection as $configValue) {
         $dbWebsiteConfig[$configValue->getPath()] = $configValue->getValue();
     }
     $dbWebsiteConfig = $this->_converter->convert($dbWebsiteConfig);
     if (count($dbWebsiteConfig)) {
         $config = array_replace_recursive($config, $dbWebsiteConfig);
     }
     return $config;
 }
コード例 #4
0
ファイル: DefaultReader.php プロジェクト: opexsw/magento2
 /**
  * Read configuration data
  *
  * @param null|string $scope
  * @throws LocalizedException Exception is thrown when scope other than default is given
  * @return array
  */
 public function read($scope = null)
 {
     $scope = $scope === null ? ScopeConfigInterface::SCOPE_TYPE_DEFAULT : $scope;
     if ($scope !== ScopeConfigInterface::SCOPE_TYPE_DEFAULT) {
         throw new \Magento\Framework\Exception\LocalizedException(__("Only default scope allowed"));
     }
     $config = $this->_initialConfig->getData($scope);
     $collection = $this->_collectionFactory->create(['scope' => $scope]);
     $dbDefaultConfig = [];
     foreach ($collection as $item) {
         $dbDefaultConfig[$item->getPath()] = $item->getValue();
     }
     $dbDefaultConfig = $this->_converter->convert($dbDefaultConfig);
     $config = array_replace_recursive($config, $dbDefaultConfig);
     return $config;
 }