Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
MetadataLoader.php
Go to the documentation of this file.
1 <?php
7 
12 
14 {
18  protected $request;
19 
24 
29 
33  protected $storeManager;
34 
41  public function __construct(
46  ) {
47  $this->request = $request;
48  $this->scopeFallbackResolver = $scopeFallbackResolver;
49  $this->designConfigRepository = $designConfigRepository;
50  $this->storeManager = $storeManager;
51  }
52 
58  public function getData()
59  {
60  $scope = $this->request->getParam('scope');
61  $scopeId = $this->request->getParam('scope_id');
62 
63  $data = [];
64  if ($scope) {
65  $showFallbackReset = false;
66  list($fallbackScope, $fallbackScopeId) = $this->scopeFallbackResolver->getFallbackScope($scope, $scopeId);
67  if ($fallbackScope && !$this->storeManager->isSingleStoreMode()) {
68  $scope = $fallbackScope;
69  $scopeId = $fallbackScopeId;
70  $showFallbackReset = true;
71  }
72 
73  $designConfig = $this->designConfigRepository->getByScope($scope, $scopeId);
74  $fieldsData = $designConfig->getExtensionAttributes()->getDesignConfigData();
75  foreach ($fieldsData as $fieldData) {
76  $element = &$data;
77  foreach (explode('/', $fieldData->getFieldConfig()['fieldset']) as $fieldset) {
78  if (!isset($element[$fieldset]['children'])) {
79  $element[$fieldset]['children'] = [];
80  }
81  $element = &$element[$fieldset]['children'];
82  }
83  $fieldName = $fieldData->getFieldConfig()['field'];
84  $element[$fieldName]['arguments']['data']['config']['default'] = $fieldData->getValue();
85  $element[$fieldName]['arguments']['data']['config']['showFallbackReset'] = $showFallbackReset;
86  }
87  }
88  return $data;
89  }
90 }
__construct(RequestInterface $request, ScopeFallbackResolverInterface $scopeFallbackResolver, DesignConfigRepositoryInterface $designConfigRepository, StoreManagerInterface $storeManager)
$element
Definition: element.phtml:12