Skip to content

Commit f7de292

Browse files
authored
MAGETWO-81993: MAGETWO-75743: Fix for #9783 Multiple <depends> parameters in widget.… #11495
2 parents 45e1c5a + 1ab1a2e commit f7de292

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

app/code/Magento/Widget/Model/Config/Converter.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ protected function _convertDepends($source)
222222
{
223223
$depends = [];
224224
foreach ($source->childNodes as $childNode) {
225-
if ($childNode->nodeName == '#text') {
225+
if ($childNode->nodeName === '#text') {
226226
continue;
227227
}
228228
if ($childNode->nodeName !== 'parameter') {
@@ -231,12 +231,23 @@ protected function _convertDepends($source)
231231
);
232232
}
233233
$parameterAttributes = $childNode->attributes;
234-
$depends[$parameterAttributes->getNamedItem(
235-
'name'
236-
)->nodeValue] = [
237-
'value' => $parameterAttributes->getNamedItem('value')->nodeValue,
238-
];
234+
$dependencyName = $parameterAttributes->getNamedItem('name')->nodeValue;
235+
$dependencyValue = $parameterAttributes->getNamedItem('value')->nodeValue;
236+
237+
if (!isset($depends[$dependencyName])) {
238+
$depends[$dependencyName] = [
239+
'value' => $dependencyValue,
240+
];
241+
242+
continue;
243+
} else if (!isset($depends[$dependencyName]['values'])) {
244+
$depends[$dependencyName]['values'] = [$depends[$dependencyName]['value']];
245+
unset($depends[$dependencyName]['value']);
246+
}
247+
248+
$depends[$dependencyName]['values'][] = $dependencyValue;
239249
}
250+
240251
return $depends;
241252
}
242253

app/code/Magento/Widget/etc/widget.xsd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@
212212
<xs:annotation>
213213
<xs:documentation>List of parameters this parameter depends on.</xs:documentation>
214214
</xs:annotation>
215-
<xs:all>
215+
<xs:sequence maxOccurs="unbounded">
216216
<xs:element name="parameter" type="dependsParameterType" />
217-
</xs:all>
217+
</xs:sequence>
218218
</xs:complexType>
219219
</xs:schema>

app/code/Magento/Widget/etc/widget_file.xsd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@
212212
<xs:annotation>
213213
<xs:documentation>List of parameters this parameter depends on.</xs:documentation>
214214
</xs:annotation>
215-
<xs:all>
215+
<xs:sequence maxOccurs="unbounded">
216216
<xs:element name="parameter" type="dependsParameterType" />
217-
</xs:all>
217+
</xs:sequence>
218218
</xs:complexType>
219219
</xs:schema>

0 commit comments

Comments
 (0)