/** * Retrieve configuration metadata * * @return array */ public function getData() { $scope = $this->request->getParam('scope'); $scopeId = $this->request->getParam('scope_id'); $data = []; if ($scope) { $showFallbackReset = false; list($fallbackScope, $fallbackScopeId) = $this->scopeFallbackResolver->getFallbackScope($scope, $scopeId); if ($fallbackScope && !$this->storeManager->isSingleStoreMode()) { $scope = $fallbackScope; $scopeId = $fallbackScopeId; $showFallbackReset = true; } $designConfig = $this->designConfigRepository->getByScope($scope, $scopeId); $fieldsData = $designConfig->getExtensionAttributes()->getDesignConfigData(); foreach ($fieldsData as $fieldData) { $element =& $data; foreach (explode('/', $fieldData->getFieldConfig()['fieldset']) as $fieldset) { if (!isset($element[$fieldset]['children'])) { $element[$fieldset]['children'] = []; } $element =& $element[$fieldset]['children']; } $fieldName = $fieldData->getFieldConfig()['field']; $element[$fieldName]['arguments']['data']['config']['default'] = $fieldData->getValue(); $element[$fieldName]['arguments']['data']['config']['showFallbackReset'] = $showFallbackReset; } } return $data; }
/** * 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; }