Skip to content

Commit d2d20da

Browse files
author
Michael Yu
committed
MC-3363: Additional configuration node changes
- Fixed documentation - Removed uneeded if statement - Updated config.php to use null coalesce
1 parent 5b3f99e commit d2d20da

File tree

2 files changed

+15
-25
lines changed

2 files changed

+15
-25
lines changed

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,12 @@ public function convert($source): array
3333
private function convertGroups(\DOMDocument $source): array
3434
{
3535
$groupsData = [];
36-
/** @var \DOMNode $source */
3736
/** @var \DOMNode $group */
3837
foreach ($source->getElementsByTagName('group') as $group) {
39-
if ($group->nodeType == XML_ELEMENT_NODE && $group->tagName == 'group') {
40-
$name = $group->attributes->getNamedItem('name')->nodeValue;
41-
/** @var \DOMElement $attributeValue */
42-
foreach ($group->attributes as $attributeName => $attributeValue) {
43-
$groupsData[$name][$attributeName] = $attributeValue->nodeValue;
44-
}
38+
$name = $group->attributes->getNamedItem('name')->nodeValue;
39+
/** @var \DOMElement $attributeValue */
40+
foreach ($group->attributes as $attributeName => $attributeValue) {
41+
$groupsData[$name][$attributeName] = $attributeValue->nodeValue;
4542
}
4643
}
4744
uasort($groupsData, function ($firstElement, $secondElement) {

app/code/Magento/PageBuilder/Model/Stage/Config.php

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -152,28 +152,21 @@ private function flattenContentTypeData($name, $contentType)
152152
'icon' => $contentType['icon'],
153153
'form' => $contentType['form'],
154154
'contentType' => '',
155-
'group' => (isset($contentType['group'])
156-
? $contentType['group'] : 'general'),
157-
'fields' => $this->uiComponentConfig->getFields($contentType['form']),
158-
'preview_template' => (isset($contentType['preview_template'])
159-
? $contentType['preview_template'] : ''),
160-
'render_template' => (isset($contentType['render_template'])
161-
? $contentType['render_template'] : ''),
155+
'group' => $contentType['group'] ?? 'general',
156+
'fields' => $this->uiComponentConfig->getFields($contentType['form'],
157+
'preview_template' => $contentType['preview_template'] ?? '',
158+
'render_template' => $contentType['render_template'] ?? '',
162159
'component' => $contentType['component'],
163-
'preview_component' => (isset($contentType['preview_component'])
164-
? $contentType['preview_component']
165-
: self::DEFAULT_PREVIEW_COMPONENT),
166-
'master_component' => (isset($contentType['master_component'])
167-
? $contentType['master_component']
168-
: self::DEFAULT_MASTER_COMPONENT),
169-
'allowed_parents' => isset($contentType['allowed_parents']) ? $contentType['allowed_parents'] : [],
170-
'readers' => isset($contentType['readers']) ? $contentType['readers'] : [],
171-
'appearances' => isset($contentType['appearances']) ? $contentType['appearances'] : [],
160+
'preview_component' => $contentType['preview_component'] ?? self::DEFAULT_PREVIEW_COMPONENT,
161+
'master_component' => $contentType['master_component'] ?? self::DEFAULT_MASTER_COMPONENT,
162+
'allowed_parents' => $contentType['allowed_parents'] ?? [],
163+
'readers' => $contentType['readers'] ?? [],
164+
'appearances' => $contentType['appearances'] ?? [],
172165
'additional_data' => isset($contentType['additional_data'])
173166
? $this->additionalDataParser->toArray($contentType['additional_data'])
174167
: [],
175-
'elements' => isset($contentType['elements']) ? $contentType['elements'] : [],
176-
'converters' => isset($contentType['converters']) ? $contentType['converters'] : [],
168+
'elements' => $contentType['elements'] ?? [],
169+
'converters' => $contentType['converters'] ?? [],
177170
'is_visible' => isset($contentType['is_visible']) && $contentType['is_visible'] === 'false' ? false : true
178171
];
179172
}

0 commit comments

Comments
 (0)