Skip to content

Commit ce07be6

Browse files
author
Michael Yu
committed
MC-2217: Add support for new config structure
- Updated content_type.xsd required attributes - Updated converter naming convention and documentation
1 parent b1ccb76 commit ce07be6

File tree

3 files changed

+9
-28
lines changed

3 files changed

+9
-28
lines changed

app/code/Magento/PageBuilder/Model/Config/ContentType/Converter.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,9 @@ private function convertTypes(\DOMDocument $source): array
5555
/** @var \DOMNode $contentType */
5656
foreach ($contentTypes as $contentType) {
5757
$name = $contentType->attributes->getNamedItem('name')->nodeValue;
58-
/** @var \DOMElement $key */
59-
/** @var \DOMElement $value */
60-
foreach ($contentType->attributes as $key => $value) {
61-
$typesData[$name][$key] = $contentType->hasAttribute($key)
62-
? $contentType->attributes->getNamedItem($key)->nodeValue
63-
: null;
58+
/** @var \DOMElement $attributeValue */
59+
foreach ($contentType->attributes as $attributeName => $attributeValue) {
60+
$typesData[$name][$attributeName] = $attributeValue->nodeValue;
6461
}
6562
/** @var \DOMElement $childNode */
6663
foreach ($contentType->childNodes as $childNode) {

app/code/Magento/PageBuilder/Model/Config/Group/Converter.php

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,9 @@ private function convertGroups(\DOMDocument $source): array
3939
foreach ($groups->item(0)->childNodes as $group) {
4040
if ($group->nodeType == XML_ELEMENT_NODE && $group->tagName == 'group') {
4141
$name = $group->attributes->getNamedItem('name')->nodeValue;
42-
/** @var \DOMElement $childNode */
43-
foreach ($group->attributes as $key => $value) {
44-
$groupsData[$name][$key] = $group->hasAttribute($key)
45-
? $group->attributes->getNamedItem($key)->nodeValue
46-
: null;
42+
/** @var \DOMElement $attributeValue */
43+
foreach ($group->attributes as $attributeName => $attributeValue) {
44+
$groupsData[$name][$attributeName] = $attributeValue->nodeValue;
4745
}
4846
}
4947
}
@@ -53,18 +51,4 @@ private function convertGroups(\DOMDocument $source): array
5351

5452
return $groupsData;
5553
}
56-
57-
/**
58-
* Check if node is configuration node
59-
*
60-
* @param \DOMNode $node
61-
* @return bool
62-
*/
63-
private function isConfigNode(\DOMNode $node): bool
64-
{
65-
return $node->nodeType === XML_ELEMENT_NODE
66-
|| ($node->nodeType === XML_CDATA_SECTION_NODE
67-
|| $node->nodeType === XML_TEXT_NODE
68-
&& trim($node->nodeValue) !== '');
69-
}
7054
}

app/code/Magento/PageBuilder/etc/content_type.xsd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
<xs:attribute type="xs:string" name="virtual" use="optional"/>
160160
</xs:complexType>
161161
<xs:complexType name="static_property">
162-
<xs:attribute type="xs:string" name="source" use="optional"/>
162+
<xs:attribute type="xs:string" name="source" use="required"/>
163163
<xs:attribute type="xs:string" name="value" use="optional"/>
164164
</xs:complexType>
165165
<xs:complexType name="attributes">
@@ -186,7 +186,7 @@
186186
<xs:attribute type="xs:boolean" name="persist" use="optional"/>
187187
</xs:complexType>
188188
<xs:complexType name="static_attribute">
189-
<xs:attribute type="xs:string" name="source" use="optional"/>
189+
<xs:attribute type="xs:string" name="source" use="required"/>
190190
<xs:attribute type="xs:string" name="value" use="optional"/>
191191
</xs:complexType>
192192
<xs:complexType name="html">
@@ -207,7 +207,7 @@
207207
</xs:sequence>
208208
</xs:complexType>
209209
<xs:complexType name="class">
210-
<xs:attribute type="xs:string" name="source" use="optional"/>
210+
<xs:attribute type="xs:string" name="source" use="required"/>
211211
</xs:complexType>
212212
<xs:complexType name="tag">
213213
<xs:attribute type="xs:string" name="name" use="required"/>

0 commit comments

Comments
 (0)