-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Fixed issue regarding widget form validation #23499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 15 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
8c38c66
Fixed issue regarding widget form validation
yash-magedelight 525de5c
The method _addField() has 104 lines of code.
yash-magedelight 2a18d24
Added translation for newly added validation for A positive non-decim…
yash-magedelight e4480a1
modified comment for function getCssClasses
yash-magedelight d5200a8
Solved Code Sniffer issues
yash-magedelight 73119c5
Solved Code Sniffer issues
yash-magedelight 75b878f
Solved Code Sniffer issues
yash-magedelight 4cfba53
Solved Code Sniffer issues
yash-magedelight 520c17a
Solved Code Sniffer issues
yash-magedelight 4805fed
Solved Code Sniffer issues
yash-magedelight 2ad1570
Solved Code Sniffer issues
yash-magedelight 0fba6ff
Solved Code Sniffer issues
yash-magedelight 924d3d7
Solved Code Sniffer issues
yash-magedelight 36698de
Solved Code Sniffer issues
yash-magedelight e521187
Solved Code Sniffer issues
yash-magedelight 119456e
Solved Code Sniffer issues
yash-magedelight b98a262
Solved Code Sniffer issues
yash-magedelight 9945c37
Strict types added
sidolov c22e210
Strict types added
sidolov 91fc99f
Merge branch '2.4-develop' of http://github.com/magento/magento2 into…
engcom-Echo 6dc7c6d
Changes covered MFTF test
engcom-Echo e7e57b9
Fix static
engcom-Echo 83cb554
Merge branch '2.4-develop' into issue-23422
VladimirZaets File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,27 @@ | |
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
/** | ||
* Widget Block Converter | ||
* | ||
* @author Magento Core Team <[email protected]> | ||
*/ | ||
namespace Magento\Widget\Model\Config; | ||
|
||
/** | ||
* Widget Converter Model | ||
* | ||
* @since 100.0.2 | ||
*/ | ||
class Converter implements \Magento\Framework\Config\ConverterInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* Convert dom node to Magento array | ||
* | ||
* @param \DOMNode $source | ||
* @return array | ||
* @throws \LogicException | ||
* @SuppressWarnings(PHPMD.NPathComplexity) | ||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) | ||
*/ | ||
|
@@ -34,56 +49,99 @@ public function convert($source) | |
$widgetId = $widgetAttributes->getNamedItem('id'); | ||
/** @var $widgetSubNode \DOMNode */ | ||
foreach ($widget->childNodes as $widgetSubNode) { | ||
switch ($widgetSubNode->nodeName) { | ||
case 'label': | ||
$widgetArray['name'] = $widgetSubNode->nodeValue; | ||
break; | ||
case 'description': | ||
$widgetArray['description'] = $widgetSubNode->nodeValue; | ||
break; | ||
case 'parameters': | ||
/** @var $parameter \DOMNode */ | ||
foreach ($widgetSubNode->childNodes as $parameter) { | ||
if ($parameter->nodeName === '#text' || $parameter->nodeName === '#comment') { | ||
continue; | ||
} | ||
$subNodeAttributes = $parameter->attributes; | ||
$parameterName = $subNodeAttributes->getNamedItem('name')->nodeValue; | ||
$widgetArray['parameters'][$parameterName] = $this->_convertParameter($parameter); | ||
} | ||
break; | ||
case 'containers': | ||
if (!isset($widgetArray['supported_containers'])) { | ||
$widgetArray['supported_containers'] = []; | ||
} | ||
foreach ($widgetSubNode->childNodes as $container) { | ||
if ($container->nodeName === '#text' || $container->nodeName === '#comment') { | ||
continue; | ||
} | ||
$widgetArray['supported_containers'] = array_merge( | ||
$widgetArray['supported_containers'], | ||
$this->_convertContainer($container) | ||
); | ||
} | ||
break; | ||
case "#text": | ||
break; | ||
case '#comment': | ||
break; | ||
default: | ||
throw new \LogicException( | ||
sprintf( | ||
"Unsupported child xml node '%s' found in the 'widget' node", | ||
$widgetSubNode->nodeName | ||
) | ||
); | ||
} | ||
$widgetArray = $this->processWidgetSubNode($widgetSubNode, $widgetArray); | ||
} | ||
$widgets[$widgetId->nodeValue] = $widgetArray; | ||
} | ||
return $widgets; | ||
} | ||
|
||
/** | ||
* Convert dom sub node to Magento array | ||
* | ||
* @param \DOMNode $widgetSubNode | ||
* @param array $widgetArray | ||
* @return array | ||
* @throws \LogicException | ||
*/ | ||
protected function processWidgetSubNode($widgetSubNode, $widgetArray) | ||
yash7690 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
switch ($widgetSubNode->nodeName) { | ||
case 'label': | ||
$widgetArray['name'] = $widgetSubNode->nodeValue; | ||
break; | ||
case 'description': | ||
$widgetArray['description'] = $widgetSubNode->nodeValue; | ||
break; | ||
case 'parameters': | ||
$widgetArray = $this->processParameters($widgetSubNode, $widgetArray); | ||
break; | ||
case 'containers': | ||
$widgetArray = $this->processContainers($widgetSubNode, $widgetArray); | ||
break; | ||
case "#text": | ||
break; | ||
case '#comment': | ||
break; | ||
default: | ||
throw new \LogicException( | ||
sprintf( | ||
"Unsupported child xml node '%s' found in the 'widget' node", | ||
$widgetSubNode->nodeName | ||
) | ||
); | ||
} | ||
|
||
return $widgetArray; | ||
} | ||
|
||
/** | ||
* Convert dom sub node to Magento array | ||
* | ||
* @param \DOMNode $widgetSubNode | ||
* @param array $widgetArray | ||
* @return array | ||
*/ | ||
protected function processParameters($widgetSubNode, $widgetArray) | ||
yash7690 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
/** @var $parameter \DOMNode */ | ||
foreach ($widgetSubNode->childNodes as $parameter) { | ||
if ($parameter->nodeName === '#text' || $parameter->nodeName === '#comment') { | ||
continue; | ||
} | ||
$subNodeAttributes = $parameter->attributes; | ||
$parameterName = $subNodeAttributes->getNamedItem('name')->nodeValue; | ||
$widgetArray['parameters'][$parameterName] = $this->_convertParameter($parameter); | ||
} | ||
|
||
return $widgetArray; | ||
} | ||
|
||
/** | ||
* Convert dom sub node to Magento array | ||
* | ||
* @param \DOMNode $widgetSubNode | ||
* @param array $widgetArray | ||
* @return array | ||
*/ | ||
protected function processContainers($widgetSubNode, $widgetArray) | ||
yash7690 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
if (!isset($widgetArray['supported_containers'])) { | ||
$widgetArray['supported_containers'] = []; | ||
} | ||
foreach ($widgetSubNode->childNodes as $container) { | ||
if ($container->nodeName === '#text' || $container->nodeName === '#comment') { | ||
continue; | ||
} | ||
$widgetArray['supported_containers'] = array_merge( | ||
$widgetArray['supported_containers'], | ||
$this->_convertContainer($container) | ||
); | ||
} | ||
|
||
return $widgetArray; | ||
} | ||
|
||
/** | ||
* Convert dom Container node to Magento array | ||
* | ||
|
@@ -208,6 +266,12 @@ protected function _convertParameter($source) | |
break; | ||
} | ||
} | ||
|
||
$additional_classes = $sourceAttributes->getNamedItem('additional_classes'); | ||
if ($additional_classes) { | ||
$parameter['additional_classes'] = $additional_classes->nodeValue; | ||
} | ||
|
||
return $parameter; | ||
} | ||
|
||
|
@@ -240,7 +304,7 @@ protected function _convertDepends($source) | |
]; | ||
|
||
continue; | ||
} else if (!isset($depends[$dependencyName]['values'])) { | ||
} elseif (!isset($depends[$dependencyName]['values'])) { | ||
$depends[$dependencyName]['values'] = [$depends[$dependencyName]['value']]; | ||
unset($depends[$dependencyName]['value']); | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.