Example #1
1
 /**
  * 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;
 }
Example #2
0
 /**
  * Read configuration by code
  *
  * @param null|string $code
  * @return array
  * @throws NoSuchEntityException
  */
 public function read($code = null)
 {
     $store = $this->_storeManager->getStore($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(['scope' => \Magento\Store\Model\ScopeInterface::SCOPE_STORES, 'scopeId' => $store->getId()]);
     $dbStoreConfig = [];
     foreach ($collection as $item) {
         $dbStoreConfig[$item->getPath()] = $item->getValue();
     }
     return $this->_converter->convert($dbStoreConfig, $config);
 }
 /**
  * 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;
 }
Example #4
0
 /**
  * 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;
 }
 /**
  * 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;
 }
Example #6
0
 public function testGetMetadata()
 {
     $expectedResult = ['metadata'];
     $this->assertEquals($expectedResult, $this->_model->getMetadata());
 }
Example #7
0
 /**
  * Retrieve all payment methods
  *
  * @return array
  */
 public function getPaymentMethods()
 {
     return $this->_initialConfig->getData('default')[self::XML_PATH_PAYMENT_METHODS];
 }