![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-theme/Model/Design/Config/DataProvider/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Theme\Model\Design\Config\DataProvider; use Magento\Framework\App\RequestInterface; use Magento\Framework\App\ScopeFallbackResolverInterface; use Magento\Theme\Api\DesignConfigRepositoryInterface; use Magento\Store\Model\StoreManagerInterface; class MetadataLoader { /** * @var RequestInterface */ protected $request; /** * @var ScopeFallbackResolverInterface */ protected $scopeFallbackResolver; /** * @var DesignConfigRepositoryInterface */ protected $designConfigRepository; /** * @var StoreManagerInterface */ protected $storeManager; /** * @param RequestInterface $request * @param ScopeFallbackResolverInterface $scopeFallbackResolver * @param DesignConfigRepositoryInterface $designConfigRepository * @param StoreManagerInterface $storeManager */ public function __construct( RequestInterface $request, ScopeFallbackResolverInterface $scopeFallbackResolver, DesignConfigRepositoryInterface $designConfigRepository, StoreManagerInterface $storeManager ) { $this->request = $request; $this->scopeFallbackResolver = $scopeFallbackResolver; $this->designConfigRepository = $designConfigRepository; $this->storeManager = $storeManager; } /** * 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; $fieldSets = isset($fieldData->getFieldConfig()['fieldset']) ? explode('/', $fieldData->getFieldConfig()['fieldset']) : []; foreach ($fieldSets as $fieldset) { // @phpstan-ignore-next-line 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; } }