From 84b0872d076bcb310f1febb550fb08addcac75ad Mon Sep 17 00:00:00 2001 From: Raul E Watson Date: Mon, 16 Oct 2017 14:17:22 +0100 Subject: [PATCH] MAGETWO-75743: Fix for #9783 Multiple parameters in widget.xml not allowed --- .../Magento/Widget/Model/Config/Converter.php | 23 ++++++++++++++----- app/code/Magento/Widget/etc/widget.xsd | 4 ++-- app/code/Magento/Widget/etc/widget_file.xsd | 4 ++-- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/app/code/Magento/Widget/Model/Config/Converter.php b/app/code/Magento/Widget/Model/Config/Converter.php index 010c46da56950..40718a5a5db9c 100644 --- a/app/code/Magento/Widget/Model/Config/Converter.php +++ b/app/code/Magento/Widget/Model/Config/Converter.php @@ -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') { @@ -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; } diff --git a/app/code/Magento/Widget/etc/widget.xsd b/app/code/Magento/Widget/etc/widget.xsd index caaeec8ac4b84..70c9ec8e3514f 100644 --- a/app/code/Magento/Widget/etc/widget.xsd +++ b/app/code/Magento/Widget/etc/widget.xsd @@ -212,8 +212,8 @@ List of parameters this parameter depends on. - + - + diff --git a/app/code/Magento/Widget/etc/widget_file.xsd b/app/code/Magento/Widget/etc/widget_file.xsd index 6ebf7a201212e..afdd506f3ba24 100644 --- a/app/code/Magento/Widget/etc/widget_file.xsd +++ b/app/code/Magento/Widget/etc/widget_file.xsd @@ -212,8 +212,8 @@ List of parameters this parameter depends on. - + - +