Beispiel #1
0
 /**
  * @inheritDoc
  */
 protected function _afterLoad()
 {
     foreach ($this->_items as $item) {
         $item->setData('value', $this->valueProcessor->process($item->getData('value'), $this->getData('scope'), $this->getData('scope_id'), $item->getData('path')));
     }
     parent::_afterLoad();
 }
 /**
  * Check whether value differs from parent scope's one
  *
  * @param string $value
  * @param string $scope
  * @param int $scopeId
  * @param string $path
  * @return bool
  */
 public function isDifferentFromDefault($value, $scope, $scopeId, $path)
 {
     list($scope, $scopeId) = $this->fallbackResolver->getFallbackScope($scope, $scopeId);
     if ($scope) {
         return !$this->isEqual($this->valueProcessor->process($value, $path), $this->valueProcessor->process($this->appConfig->getValue($path, $scope, $scopeId), $path));
     }
     return true;
 }
 public function testProcess()
 {
     $path = 'design/head/logo';
     $value = 'path/to/logo';
     $this->backendModelFactory->expects($this->once())->method('createByPath')->with($path, ['value' => $value])->willReturn($this->backendModel);
     $this->backendModel->expects($this->once())->method('afterLoad');
     $this->backendModel->expects($this->once())->method('getValue')->willReturn($value);
     $this->assertEquals($value, $this->valueProcessor->process($value, $path));
 }
 public function testProcess()
 {
     $path = 'design/head/logo';
     $value = 'path/to/logo';
     $scope = 'websites';
     $scopeId = 1;
     $this->backendModelFactory->expects($this->once())->method('createByPath')->with($path, ['value' => $value, 'field_config' => ['path' => $path], 'scope' => $scope, 'scope_id' => $scopeId])->willReturn($this->backendModel);
     $this->backendModel->expects($this->once())->method('afterLoad');
     $this->backendModel->expects($this->once())->method('getValue')->willReturn($value);
     $this->assertEquals($value, $this->valueProcessor->process($value, $scope, $scopeId, ['path' => $path]));
 }
 /**
  * Load design config from storage
  *
  * @param string $scope
  * @param mixed $scopeId
  * @return DesignConfigInterface
  */
 public function load($scope, $scopeId)
 {
     $designConfig = $this->configFactory->create($scope, $scopeId);
     $fieldsData = $designConfig->getExtensionAttributes()->getDesignConfigData();
     foreach ($fieldsData as &$fieldData) {
         $value = $this->valueProcessor->process($this->scopeConfig->getValue($fieldData->getPath(), $scope, $scopeId), $fieldData->getPath());
         if ($value !== null) {
             $fieldData->setValue($value);
         }
     }
     return $designConfig;
 }
 /**
  * Retrieve fields metadata
  *
  * @param string $scope
  * @param int $scopeId
  * @return array
  */
 protected function getMetadataValues($scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeId = null)
 {
     $result = [];
     foreach ($this->metadataProvider->get() as $itemName => $itemData) {
         if (isset($itemData['use_in_grid']) && (bool) $itemData['use_in_grid']) {
             $result[$itemName] = $this->valueProcessor->process($this->appConfig->getValue($itemData['path'], $scope, $scopeId), $itemData['path']);
         }
     }
     return $result;
 }