Author: Romain Ruaud (romain.ruaud@smile.fr)
コード例 #1
0
ファイル: Container.php プロジェクト: smile-sa/elasticsuite
 /**
  * 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;
 }
コード例 #2
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;
 }
コード例 #3
0
 /**
  * Read configuration data
  *
  * @param null|string $scope The current scope to load (default)
  *
  * @return array Exception is thrown when scope other than default is given
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function read($scope = null)
 {
     $scope = $scope === null ? ContainerScopeInterface::SCOPE_DEFAULT : $scope;
     if ($scope !== ContainerScopeInterface::SCOPE_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;
 }