Skip to content

Commit 3bf029d

Browse files
committed
Merge branch 'MC-5810' into cms-team-1-delivery
# Conflicts: # app/code/Magento/PageBuilder/Test/Mftf/Section/PageBuilderMapSection.xml # app/code/Magento/PageBuilder/Test/Mftf/Test/AdminPageBuilderSlideItemCommonTest.xml # app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/column-group/preview.js # app/code/Magento/PageBuilder/view/adminhtml/web/js/master-format/read/configurable.js # app/code/Magento/PageBuilder/view/adminhtml/web/js/stage-builder.js # app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type/column-group/preview.ts # app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/master-format/read/configurable.ts # app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/stage-builder.ts
2 parents 77e9b6e + 61d3503 commit 3bf029d

File tree

404 files changed

+3745
-3814
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

404 files changed

+3745
-3814
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
use Magento\Framework\App\Config\ScopeConfigInterface;
1212

13+
/**
14+
* Represents PageBuilder loaded and cached configuration data
15+
*/
1316
class Config extends \Magento\Framework\Config\Data implements \Magento\PageBuilder\Model\ConfigInterface
1417
{
1518
const IS_PAGEBUILDER_ENABLED = 'cms/pagebuilder/enabled';
@@ -36,11 +39,13 @@ public function __construct(
3639
}
3740

3841
/**
42+
* Return all menu sections
43+
*
3944
* @return array
4045
*/
41-
public function getGroups() : array
46+
public function getMenuSections() : array
4247
{
43-
return $this->get('groups');
48+
return $this->get('menu_sections');
4449
}
4550

4651
/**

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
use Magento\Framework\ObjectManager\Config\Mapper\ArgumentParser;
1212

13+
/**
14+
* Convert content type configuration data
15+
*/
1316
class Converter implements \Magento\Framework\Config\ConverterInterface
1417
{
1518
const DEFAULT_ATTRIBUTE_READER = 'Magento_PageBuilder/js/property/attribute-reader';
@@ -133,7 +136,7 @@ private function convertAppearanceData(\DOMElement $appearanceNode): array
133136
}
134137
$appearanceData['converters'] = $this->convertConvertersData($appearanceNode);
135138
$appearanceData['preview_template'] = $this->getAttributeValue($appearanceNode, 'preview_template');
136-
$appearanceData['render_template'] = $this->getAttributeValue($appearanceNode, 'render_template');
139+
$appearanceData['master_template'] = $this->getAttributeValue($appearanceNode, 'master_template');
137140
$appearanceData['reader'] = $this->getAttributeValue($appearanceNode, 'reader');
138141
$appearanceData['default'] = $this->getAttributeValue($appearanceNode, 'default');
139142
$formNode = $appearanceNode->getElementsByTagName('form')->item(0);
@@ -357,7 +360,9 @@ private function convertTag(\DOMElement $elementNode): array
357360
}
358361

359362
/**
360-
* @param \DOMElement $childNode
363+
* Converts converter data
364+
*
365+
* @param \DOMElement $appearanceNode
361366
* @return array
362367
*/
363368
private function convertConvertersData(\DOMElement $appearanceNode): array
@@ -519,11 +524,11 @@ private function isConfigNode(\DOMNode $node): bool
519524
/**
520525
* Get attribute value
521526
*
522-
* @param $attributeNode
523-
* @param $attributeName
527+
* @param \DOMElement $attributeNode
528+
* @param string $attributeName
524529
* @return string|null
525530
*/
526-
private function getAttributeValue(\DOMElement $attributeNode, $attributeName)
531+
private function getAttributeValue(\DOMElement $attributeNode, string $attributeName)
527532
{
528533
return $attributeNode->hasAttribute($attributeName)
529534
? $attributeNode->attributes->getNamedItem($attributeName)->nodeValue
@@ -545,8 +550,8 @@ private function extractVariableName(\DOMElement $node): string
545550
/**
546551
* Remove data from array
547552
*
548-
* @param $searchValue
549-
* @param $data
553+
* @param string $searchValue
554+
* @param array $data
550555
* @return array
551556
*/
552557
private function removeDataInArray(string $searchValue, array $data): array

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

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\PageBuilder\Model\Config\MenuSection;
10+
11+
/**
12+
* Converter for menu section in configuration
13+
*/
14+
class Converter implements \Magento\Framework\Config\ConverterInterface
15+
{
16+
/**
17+
* Convert XML structure into output array
18+
*
19+
* @param \DOMDocument $source
20+
* @return array
21+
* @throws \InvalidArgumentException
22+
*/
23+
public function convert($source): array
24+
{
25+
return [
26+
'menu_sections' => $this->convertMenuSections($source)
27+
];
28+
}
29+
30+
/**
31+
* Convert data for menu sections
32+
*
33+
* @param \DOMDocument $source
34+
* @return array
35+
*/
36+
private function convertMenuSections(\DOMDocument $source): array
37+
{
38+
$menuSectionsData = [];
39+
/** @var \DOMNode $menuSection */
40+
foreach ($source->getElementsByTagName('menu_section') as $menuSection) {
41+
$name = $menuSection->attributes->getNamedItem('name')->nodeValue;
42+
/** @var \DOMElement $attributeValue */
43+
foreach ($menuSection->attributes as $attributeName => $attributeValue) {
44+
$menuSectionsData[$name][$attributeName] = $attributeValue->nodeValue;
45+
}
46+
}
47+
uasort($menuSectionsData, function ($firstElement, $secondElement) {
48+
return (int)$firstElement['sortOrder'] <=> (int)$secondElement['sortOrder'];
49+
});
50+
51+
return $menuSectionsData;
52+
}
53+
}

app/code/Magento/PageBuilder/Model/Config/Group/Reader.php renamed to app/code/Magento/PageBuilder/Model/Config/MenuSection/Reader.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66

77
declare(strict_types=1);
88

9-
namespace Magento\PageBuilder\Model\Config\Group;
9+
namespace Magento\PageBuilder\Model\Config\MenuSection;
1010

11+
/**
12+
* Reader for menu section in configuration
13+
*/
1114
class Reader extends \Magento\Framework\Config\Reader\Filesystem
1215
{
1316
/**
@@ -16,15 +19,15 @@ class Reader extends \Magento\Framework\Config\Reader\Filesystem
1619
* @var array
1720
*/
1821
protected $_idAttributes = [
19-
'/config/group' => 'name'
22+
'/config/menu_section' => 'name'
2023
];
2124

2225
/**
2326
* Constructor
2427
*
2528
* @param \Magento\PageBuilder\Model\Config\FileResolver $fileResolver
26-
* @param \Magento\PageBuilder\Model\Config\Group\Converter $converter
27-
* @param \Magento\PageBuilder\Model\Config\Group\SchemaLocator $schemaLocator
29+
* @param \Magento\PageBuilder\Model\Config\MenuSection\Converter $converter
30+
* @param \Magento\PageBuilder\Model\Config\MenuSection\SchemaLocator $schemaLocator
2831
* @param \Magento\Framework\Config\ValidationStateInterface $validationState
2932
* @param string $fileName
3033
* @param array $idAttributes
@@ -33,10 +36,10 @@ class Reader extends \Magento\Framework\Config\Reader\Filesystem
3336
*/
3437
public function __construct(
3538
\Magento\PageBuilder\Model\Config\FileResolver $fileResolver,
36-
\Magento\PageBuilder\Model\Config\Group\Converter $converter,
37-
\Magento\PageBuilder\Model\Config\Group\SchemaLocator $schemaLocator,
39+
\Magento\PageBuilder\Model\Config\MenuSection\Converter $converter,
40+
\Magento\PageBuilder\Model\Config\MenuSection\SchemaLocator $schemaLocator,
3841
\Magento\Framework\Config\ValidationStateInterface $validationState,
39-
string $fileName = 'group.xml',
42+
string $fileName = 'menu_section.xml',
4043
array $idAttributes = [],
4144
string $domDocumentClass = \Magento\Framework\Config\Dom::class,
4245
string $defaultScope = 'global'

app/code/Magento/PageBuilder/Model/Config/Group/SchemaLocator.php renamed to app/code/Magento/PageBuilder/Model/Config/MenuSection/SchemaLocator.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66

77
declare(strict_types=1);
88

9-
namespace Magento\PageBuilder\Model\Config\Group;
9+
namespace Magento\PageBuilder\Model\Config\MenuSection;
1010

11+
/**
12+
* Schema locator for menu section in configuration
13+
*/
1114
class SchemaLocator implements \Magento\Framework\Config\SchemaLocatorInterface
1215
{
1316
/**
@@ -31,8 +34,8 @@ public function __construct(
3134
\Magento\Framework\Module\Dir\Reader $moduleReader
3235
) {
3336
$etcDir = $moduleReader->getModuleDir('etc', 'Magento_PageBuilder');
34-
$this->schema = $etcDir . DIRECTORY_SEPARATOR . 'group_merged.xsd';
35-
$this->perFileSchema = $etcDir . DIRECTORY_SEPARATOR . 'group.xsd';
37+
$this->schema = $etcDir . DIRECTORY_SEPARATOR . 'menu_section_merged.xsd';
38+
$this->perFileSchema = $etcDir . DIRECTORY_SEPARATOR . 'menu_section.xsd';
3639
}
3740

3841
/**

app/code/Magento/PageBuilder/Model/ConfigInterface.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,22 @@
1515
interface ConfigInterface
1616
{
1717
/**
18+
* Gets all the menu sections
19+
*
1820
* @return array
1921
*/
20-
public function getGroups() : array;
22+
public function getMenuSections() : array;
2123

2224
/**
25+
* Gets all the content types
26+
*
2327
* @return array
2428
*/
2529
public function getContentTypes() : array;
2630

2731
/**
32+
* Get if PageBuilder is enabled
33+
*
2834
* @return bool
2935
*/
3036
public function isEnabled() : bool;

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function __construct(
131131
public function getConfig()
132132
{
133133
return [
134-
'groups' => $this->getGroups(),
134+
'menu_sections' => $this->getMenuSections(),
135135
'content_types' => $this->getContentTypes(),
136136
'stage_config' => $this->data,
137137
'media_url' => $this->urlBuilder->getBaseUrl(['_type' => UrlInterface::URL_TYPE_MEDIA]),
@@ -144,13 +144,13 @@ public function getConfig()
144144
}
145145

146146
/**
147-
* Retrieve the content type groups
147+
* Retrieve the content type menu sections
148148
*
149149
* @return array
150150
*/
151-
private function getGroups()
151+
private function getMenuSections()
152152
{
153-
return $this->config->getGroups();
153+
return $this->config->getMenuSections();
154154
}
155155

156156
/**
@@ -194,7 +194,7 @@ private function flattenContentTypeData(string $name, array $contentType)
194194
'label' => $contentType['label'],
195195
'icon' => isset($contentType['icon']) ? $contentType['icon'] : '',
196196
'form' => isset($contentType['form']) ? $contentType['form'] : '',
197-
'group' => $contentType['group'] ?? 'general',
197+
'menu_section' => $contentType['menu_section'] ?? 'general',
198198
'fields' => isset($contentType['form']) ? $this->uiComponentConfig->getFields($contentType['form']) : [],
199199
'component' => $contentType['component'],
200200
'preview_component' => $contentType['preview_component'] ?? self::DEFAULT_PREVIEW_COMPONENT,
@@ -204,7 +204,7 @@ private function flattenContentTypeData(string $name, array $contentType)
204204
'additional_data' => isset($contentType['additional_data'])
205205
? $this->additionalDataParser->toArray($contentType['additional_data'])
206206
: [],
207-
'is_visible' => isset($contentType['is_visible']) && $contentType['is_visible'] === 'false' ? false : true
207+
'is_system' => isset($contentType['is_system']) && $contentType['is_system'] === 'false' ? false : true
208208
];
209209
}
210210

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ public function filterHtml(string $content): string
5454
$item->parentNode->removeChild($item);
5555
}
5656
$xpath = new \DOMXPath($dom);
57-
$htmlContentTypes = $xpath->query('//*[@data-role="html" and not(contains(@class, "placeholder-html-code"))]');
57+
$htmlContentTypes = $xpath->query(
58+
'//*[@data-content-type="html" and not(contains(@class, "placeholder-html-code"))]'
59+
);
5860
foreach ($htmlContentTypes as $htmlContentType) {
5961
/* @var \DOMElement $htmlContentType */
6062
$innerHTML= '';

app/code/Magento/PageBuilder/Model/WidgetInitializerConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function getConfig(): array
3535
{
3636
$resultConfig = [];
3737
foreach ($this->config as $contentTypeName => $config) {
38-
$selector = sprintf('[data-role="%s"]', $contentTypeName);
38+
$selector = sprintf('[data-content-type="%s"]', $contentTypeName);
3939
foreach ($config as $item) {
4040
if (!isset($item['component'])) {
4141
continue;

0 commit comments

Comments
 (0)