Skip to content

Commit

Permalink
⏫ Forwardport of #11495 to 2.3-develop branch
Browse files Browse the repository at this point in the history
Applied pull request patch https://github.com/magento/magento2/pull/11495.patch (created by @diazwatson) based on commit(s):
  1. 84b0872

Fixed GitHub Issues in 2.3-develop branch:
  - #9783: Multiple <depends> parameters in widget.xml not allowed (reported by @milansimek)
  • Loading branch information
magento-engcom-team committed Jan 23, 2018
1 parent 8e77e2f commit 5e02b15
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
23 changes: 17 additions & 6 deletions app/code/Magento/Widget/Model/Config/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ protected function _convertDepends($source)
{
$depends = [];
foreach ($source->childNodes as $childNode) {
if ($childNode->nodeName == '#text') {
if ($childNode->nodeName === '#text') {
continue;
}
if ($childNode->nodeName !== 'parameter') {
Expand All @@ -231,12 +231,23 @@ protected function _convertDepends($source)
);
}
$parameterAttributes = $childNode->attributes;
$depends[$parameterAttributes->getNamedItem(
'name'
)->nodeValue] = [
'value' => $parameterAttributes->getNamedItem('value')->nodeValue,
];
$dependencyName = $parameterAttributes->getNamedItem('name')->nodeValue;
$dependencyValue = $parameterAttributes->getNamedItem('value')->nodeValue;

if (!isset($depends[$dependencyName])) {
$depends[$dependencyName] = [
'value' => $dependencyValue,
];

continue;
} else if (!isset($depends[$dependencyName]['values'])) {
$depends[$dependencyName]['values'] = [$depends[$dependencyName]['value']];
unset($depends[$dependencyName]['value']);
}

$depends[$dependencyName]['values'][] = $dependencyValue;
}

return $depends;
}

Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Widget/etc/widget.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@
<xs:annotation>
<xs:documentation>List of parameters this parameter depends on.</xs:documentation>
</xs:annotation>
<xs:all>
<xs:sequence maxOccurs="unbounded">
<xs:element name="parameter" type="dependsParameterType" />
</xs:all>
</xs:sequence>
</xs:complexType>
</xs:schema>
4 changes: 2 additions & 2 deletions app/code/Magento/Widget/etc/widget_file.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@
<xs:annotation>
<xs:documentation>List of parameters this parameter depends on.</xs:documentation>
</xs:annotation>
<xs:all>
<xs:sequence maxOccurs="unbounded">
<xs:element name="parameter" type="dependsParameterType" />
</xs:all>
</xs:sequence>
</xs:complexType>
</xs:schema>

0 comments on commit 5e02b15

Please sign in to comment.