/**
  * 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 #2
0
 /**
  * Read configuration by code
  *
  * @param null|string $code The container code
  *
  * @return array
  */
 public function read($code = null)
 {
     $config = array_replace_recursive($this->defaultReader->read(ContainerScopeInterface::SCOPE_DEFAULT), $this->initialConfig->getData($code));
     $collection = $this->collectionFactory->create(['scope' => ContainerScopeInterface::SCOPE_CONTAINERS, 'scopeCode' => $code]);
     $dbContainerConfig = [];
     foreach ($collection as $item) {
         $dbContainerConfig[$item->getPath()] = $item->getValue();
     }
     $dbContainerConfig = $this->converter->convert($dbContainerConfig);
     if (count($dbContainerConfig)) {
         $config = array_replace_recursive($config, $dbContainerConfig);
     }
     return $config;
 }
Example #3
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 #5
0
 public function testConvert()
 {
     $data = ['some/config/path1' => 'value1', 'some/config/path2' => 'value2'];
     $expectedResult = ['some' => ['config' => ['path1' => 'value1', 'path2' => 'value2']]];
     $this->assertEquals($expectedResult, $this->_model->convert($data));
 }
Example #6
0
 /**
  * Convert config data
  *
  * @param array $source
  * @param array $initialConfig
  * @return array
  */
 public function convert($source, $initialConfig = [])
 {
     $config = array_replace_recursive($initialConfig, parent::convert($source));
     return $this->_processor->process($config);
 }