Пример #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;
 }
Пример #2
0
 public function testConvert()
 {
     $initial = array('path' => array('to' => array('save' => 'saved value', 'overwrite' => 'old value')));
     $source = array('path/to/overwrite' => 'overwritten', 'path/to/added' => 'added value');
     $mergeResult = array('path' => array('to' => array('save' => 'saved value', 'overwrite' => 'overwritten', 'added' => 'added value')));
     $processorResult = '123Value';
     $this->_processorMock->expects($this->once())->method('process')->with($mergeResult)->will($this->returnValue($processorResult));
     $this->assertEquals($processorResult, $this->_model->convert($source, $initial));
 }
Пример #3
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);
 }
Пример #4
0
 /**
  * Read configuration by code
  *
  * @param null|string $code The container code
  *
  * @return array
  */
 public function read($code = null)
 {
     list($containerCode, $storeId) = explode("|", $code);
     $store = $this->storeManager->getStore($storeId);
     $config = array_replace_recursive($this->containerReader->read($containerCode), $this->initialConfig->getData("{$containerCode}|{$store->getCode()}"));
     $collection = $this->collectionFactory->create(['scope' => ContainerScopeInterface::SCOPE_STORE_CONTAINERS, 'scopeCode' => $code]);
     $dbStoreConfig = [];
     foreach ($collection as $item) {
         $dbStoreConfig[$item->getPath()] = $item->getValue();
     }
     $dbStoreConfig = $this->converter->convert($dbStoreConfig);
     $config = array_replace_recursive($config, $dbStoreConfig);
     return $config;
 }