Skip to content

Commit 214d3f2

Browse files
authored
Merge pull request #217 from magento-obsessive-owls/cms-team-1-delivery
[Owls] Beta Release 7, part 2
2 parents b59da88 + 6adf298 commit 214d3f2

File tree

658 files changed

+13616
-14162
lines changed

Some content is hidden

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

658 files changed

+13616
-14162
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "page-builder-types"]
2+
path = page-builder-types
3+
url = [email protected]:magento-obsessive-owls/page-builder-types.git

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,31 @@ We will push new beta releases once a week, including work from the backlog. We
2323

2424
To participate in technical discussions and ask questions, join us in [Slack], where a number of Page Builder team members are present.
2525

26+
## TypeScript
27+
This module utilises TypeScript within our adminhtml web directory. This requires an additional build step or watch command to be running during development on this module.
28+
29+
We use a combination of `tsc` from TypeScript and Babel 7.* with the TypeScript env. This enables us to have fast build times for the large TypeScript code base we have.
30+
31+
#### `npx ts:build`
32+
Runs a single build of all TypeScript files within the defined directory. This utilises Babel with the TypeScript present.
33+
34+
#### `npx ts:watch`
35+
Runs a continuous watch of files and builds them as it detects file changes.
36+
37+
#### `npx ts:lint`
38+
Runs TSLint to verify linting of all TypeScript files
39+
40+
#### `npx ts:defs`
41+
Generates TypeScript definitions for the whole module to be published as a types package.
42+
43+
#### `npx ts:errors`
44+
Displays any TypeScript errors currently within the code base. This utilises `tsc` with the no emit flag.
45+
46+
#### `npx ts:errors:watch`
47+
Same as above but watches for file changes.
48+
49+
#### `npx start`
50+
Command used to start development on this module, uses `concurrently` to spawn instances of `npx ts:watch` and `npx ts:errors:watch`.
2651

2752
[Contribution Guide]: CONTRIBUTING.md
2853
[Slack]: https://magentocommeng.slack.com/messages/GANS1R4C9

app/code/Magento/PageBuilder/Block/GoogleMapsApi.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function getStyle(): ?string
5858
public function getInvalidApiKeyMessage(): \Magento\Framework\Phrase
5959
{
6060
return __(
61-
"You must provide a valid <a href='%1'>Google Maps API key</a> to use a map.",
61+
"You must provide a valid <a href='%1' target='_blank'>Google Maps API key</a> to use a map.",
6262
$this->_urlBuilder->getUrl('adminhtml/system_config/edit/section/cms', ['_fragment' => 'cms_pagebuilder'])
6363
);
6464
}

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

+7-2
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

+12-7
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

-50
This file was deleted.
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 app/code/Magento/PageBuilder/Model/Config/MenuSection/Reader.php

+10-7
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 app/code/Magento/PageBuilder/Model/Config/MenuSection/SchemaLocator.php

+6-3
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

+7-1
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;

0 commit comments

Comments
 (0)