Skip to content

Commit 86cfbe7

Browse files
author
Volodymyr Kublytskyi
committed
Merge magento-partners/magento2ce#15.
2 parents 483bf34 + 7f79e6f commit 86cfbe7

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

app/code/Magento/Theme/Model/Design/Config/Validator.php

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,8 @@ public function validate(DesignConfigInterface $designConfig)
6464
}
6565

6666
foreach ($elements as $name => $data) {
67-
// Load template object by configured template id
68-
$template = $this->templateFactory->create();
69-
$template->emulateDesign($designConfig->getScopeId());
7067
$templateId = $data['value'];
71-
if (is_numeric($templateId)) {
72-
$template->load($templateId);
73-
} else {
74-
$template->loadDefault($templateId);
75-
}
76-
$text = $template->getTemplateText();
77-
$template->revertDesign();
68+
$text = $this->getTemplateText($templateId, $designConfig);
7869
// Check if template body has a reference to the same config path
7970
if (preg_match_all(Template::CONSTRUCTION_TEMPLATE_PATTERN, $text, $constructions, PREG_SET_ORDER)) {
8071
foreach ($constructions as $construction) {
@@ -94,6 +85,37 @@ public function validate(DesignConfigInterface $designConfig)
9485
}
9586
}
9687

88+
/**
89+
* @param $designConfig
90+
* @return mixed
91+
*/
92+
private function getScopeId($designConfig)
93+
{
94+
if ($designConfig->getScope() == 'stores') {
95+
return $designConfig->getScopeId();
96+
}
97+
return false;
98+
}
99+
100+
/**
101+
* @param $designConfig
102+
* @return mixed
103+
*/
104+
private function getTemplateText($templateId, $designConfig)
105+
{
106+
// Load template object by configured template id
107+
$template = $this->templateFactory->create();
108+
$template->emulateDesign($this->getScopeId($designConfig));
109+
if (is_numeric($templateId)) {
110+
$template->load($templateId);
111+
} else {
112+
$template->loadDefault($templateId);
113+
}
114+
$text = $template->getTemplateText();
115+
$template->revertDesign();
116+
return $text;
117+
}
118+
97119
/**
98120
* Return associative array of parameters.
99121
*

0 commit comments

Comments
 (0)