Skip to content

Commit f153efd

Browse files
committed
Merge remote-tracking branch 'mainline/develop' into cms-pagebuilder-test-debt-hackathon-1
2 parents ebc8834 + 72713ab commit f153efd

Some content is hidden

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

65 files changed

+1552
-1050
lines changed

app/code/Magento/PageBuilder/Model/Config/ContentTypes/AdditionalData/Provider/StoreId.php renamed to app/code/Magento/PageBuilder/Model/Config/ContentType/AdditionalData/Provider/StoreId.php

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

77
declare(strict_types=1);
88

9-
namespace Magento\PageBuilder\Model\Config\ContentTypes\AdditionalData\Provider;
9+
namespace Magento\PageBuilder\Model\Config\ContentType\AdditionalData\Provider;
1010

11-
use Magento\PageBuilder\Model\Config\ContentTypes\AdditionalData\ProviderInterface;
11+
use Magento\PageBuilder\Model\Config\ContentType\AdditionalData\ProviderInterface;
1212
use Magento\Store\Model\StoreManagerInterface;
1313

1414
/**
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
declare(strict_types=1);
88

9-
namespace Magento\PageBuilder\Model\Config\ContentTypes\AdditionalData\Provider\Uploader;
9+
namespace Magento\PageBuilder\Model\Config\ContentType\AdditionalData\Provider\Uploader;
1010

11-
use Magento\PageBuilder\Model\Config\ContentTypes\AdditionalData\ProviderInterface;
11+
use Magento\PageBuilder\Model\Config\ContentType\AdditionalData\ProviderInterface;
1212
use Magento\Framework\File\Size;
1313

1414
/**
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
declare(strict_types=1);
88

9-
namespace Magento\PageBuilder\Model\Config\ContentTypes\AdditionalData\Provider\Uploader;
9+
namespace Magento\PageBuilder\Model\Config\ContentType\AdditionalData\Provider\Uploader;
1010

11-
use Magento\PageBuilder\Model\Config\ContentTypes\AdditionalData\ProviderInterface;
11+
use Magento\PageBuilder\Model\Config\ContentType\AdditionalData\ProviderInterface;
1212
use Magento\Framework\View\Element\UiComponent\ContextInterface;
1313

1414
/**
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
declare(strict_types=1);
88

9-
namespace Magento\PageBuilder\Model\Config\ContentTypes\AdditionalData\Provider\Uploader;
9+
namespace Magento\PageBuilder\Model\Config\ContentType\AdditionalData\Provider\Uploader;
1010

11-
use Magento\PageBuilder\Model\Config\ContentTypes\AdditionalData\ProviderInterface;
11+
use Magento\PageBuilder\Model\Config\ContentType\AdditionalData\ProviderInterface;
1212
use Magento\Framework\View\Element\UiComponent\ContextInterface;
1313

1414
/**

app/code/Magento/PageBuilder/Model/Config/ContentTypes/AdditionalData/ProviderInterface.php renamed to app/code/Magento/PageBuilder/Model/Config/ContentType/AdditionalData/ProviderInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
declare(strict_types=1);
88

9-
namespace Magento\PageBuilder\Model\Config\ContentTypes\AdditionalData;
9+
namespace Magento\PageBuilder\Model\Config\ContentType\AdditionalData;
1010

1111
/**
1212
* Provides runtime-specific data for additional data content types configuration

app/code/Magento/PageBuilder/Model/Config/ContentTypes/Converter.php renamed to app/code/Magento/PageBuilder/Model/Config/ContentType/Converter.php

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

77
declare(strict_types=1);
88

9-
namespace Magento\PageBuilder\Model\Config\ContentTypes;
9+
namespace Magento\PageBuilder\Model\Config\ContentType;
1010

1111
use Magento\Framework\ObjectManager\Config\Mapper\ArgumentParser;
1212
use Magento\Framework\Data\Argument\InterpreterInterface;
13-
use Magento\PageBuilder\Model\Config\ContentTypes\AdditionalData\ProviderInterface;
13+
use Magento\PageBuilder\Model\Config\ContentType\AdditionalData\ProviderInterface;
1414

1515
class Converter implements \Magento\Framework\Config\ConverterInterface
1616
{
@@ -274,8 +274,8 @@ private function convertProperties(\DOMElement $elementNode): array
274274
if ($propertiesNode) {
275275
foreach ($propertiesNode->getElementsByTagName('property') as $propertyNode) {
276276
$propertiesData[] = [
277-
'var' => $this->getAttributeValue($propertyNode, 'var'),
278-
'name' => $this->getAttributeValue($propertyNode, 'name'),
277+
'var' => $this->getAttributeValue($propertyNode, 'name'),
278+
'name' => $this->getAttributeValue($propertyNode, 'source'),
279279
'converter' => $this->getAttributeValue($propertyNode, 'converter'),
280280
'preview_converter' => $this->getAttributeValue($propertyNode, 'preview_converter'),
281281
'virtual' => $this->getAttributeValue($propertyNode, 'virtual'),
@@ -284,7 +284,7 @@ private function convertProperties(\DOMElement $elementNode): array
284284
}
285285
foreach ($propertiesNode->getElementsByTagName('complex_property') as $propertyNode) {
286286
$propertiesData[] = [
287-
'var' => $this->getAttributeValue($propertyNode, 'var'),
287+
'var' => $this->getAttributeValue($propertyNode, 'name'),
288288
'reader' => $this->getAttributeValue($propertyNode, 'reader'),
289289
'converter' => $this->getAttributeValue($propertyNode, 'converter'),
290290
'preview_converter' => $this->getAttributeValue($propertyNode, 'preview_converter'),
@@ -294,7 +294,7 @@ private function convertProperties(\DOMElement $elementNode): array
294294
}
295295
foreach ($propertiesNode->getElementsByTagName('static_property') as $propertyNode) {
296296
$propertiesData[] = [
297-
'name' => $this->getAttributeValue($propertyNode, 'name'),
297+
'name' => $this->getAttributeValue($propertyNode, 'source'),
298298
'value' => $this->getAttributeValue($propertyNode, 'value'),
299299
'static' => true
300300
];
@@ -316,8 +316,8 @@ private function convertAttributes(\DOMElement $elementNode): array
316316
if ($attributesNode) {
317317
foreach ($attributesNode->getElementsByTagName('attribute') as $attributeNode) {
318318
$attributesData[] = [
319-
'var' => $this->getAttributeValue($attributeNode, 'var'),
320-
'name' => $this->getAttributeValue($attributeNode, 'name'),
319+
'var' => $this->getAttributeValue($attributeNode, 'name'),
320+
'name' => $this->getAttributeValue($attributeNode, 'source'),
321321
'converter' => $this->getAttributeValue($attributeNode, 'converter'),
322322
'preview_converter' => $this->getAttributeValue($attributeNode, 'preview_converter'),
323323
'virtual' => $this->getAttributeValue($attributeNode, 'virtual'),
@@ -326,14 +326,14 @@ private function convertAttributes(\DOMElement $elementNode): array
326326
}
327327
foreach ($attributesNode->getElementsByTagName('static_attribute') as $attributeNode) {
328328
$attributesData[] = [
329-
'name' => $this->getAttributeValue($attributeNode, 'name'),
329+
'name' => $this->getAttributeValue($attributeNode, 'source'),
330330
'value' => $this->getAttributeValue($attributeNode, 'value'),
331331
'static' => true
332332
];
333333
}
334334
foreach ($attributesNode->getElementsByTagName('complex_attribute') as $attributeNode) {
335335
$attributesData[] = [
336-
'var' => $this->getAttributeValue($attributeNode, 'var'),
336+
'var' => $this->getAttributeValue($attributeNode, 'name'),
337337
'reader' => $this->getAttributeValue($attributeNode, 'reader'),
338338
'converter' => $this->getAttributeValue($attributeNode, 'converter'),
339339
'preview_converter' => $this->getAttributeValue($attributeNode, 'preview_converter'),
@@ -357,7 +357,7 @@ private function convertHtml(\DOMElement $elementNode): array
357357
$htmlData = [];
358358
$htmlNode = $elementNode->getElementsByTagName('html')->item(0);
359359
if ($htmlNode) {
360-
$htmlData['var']= $this->getAttributeValue($htmlNode, 'var');
360+
$htmlData['var']= $this->getAttributeValue($htmlNode, 'name');
361361
$htmlData['converter'] = $this->getAttributeValue($htmlNode, 'converter');
362362
$htmlData['preview_converter'] = $this->getAttributeValue($htmlNode, 'preview_converter');
363363
}
@@ -375,13 +375,13 @@ private function convertCss(\DOMElement $elementNode): array
375375
$cssData = [];
376376
$cssNode = $elementNode->getElementsByTagName('css')->item(0);
377377
if ($cssNode) {
378-
$cssData['var'] = $this->getAttributeValue($cssNode, 'var');
378+
$cssData['var'] = $this->getAttributeValue($cssNode, 'name');
379379
$cssData['converter'] = $this->getAttributeValue($cssNode, 'converter');
380380
$filterClasses = [];
381381
$filterNode = $cssNode->getElementsByTagName('filter')->item(0);
382382
if ($filterNode) {
383383
foreach ($filterNode->getElementsByTagName('class') as $classNode) {
384-
$filterClasses[] = $this->getAttributeValue($classNode, 'name');
384+
$filterClasses[] = $this->getAttributeValue($classNode, 'source');
385385
}
386386
}
387387
$cssData['filter'] = $filterClasses;
@@ -400,7 +400,7 @@ private function convertTag(\DOMElement $elementNode): array
400400
$tagData = [];
401401
$tagNode = $elementNode->getElementsByTagName('tag')->item(0);
402402
if ($tagNode) {
403-
$tagData['var'] = $this->getAttributeValue($tagNode, 'var');
403+
$tagData['var'] = $this->getAttributeValue($tagNode, 'name');
404404
$tagData['converter'] = $this->getAttributeValue($tagNode, 'converter');
405405
}
406406
return $tagData;

app/code/Magento/PageBuilder/Model/Config/ContentTypes/Reader.php renamed to app/code/Magento/PageBuilder/Model/Config/ContentType/Reader.php

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

77
declare(strict_types=1);
88

9-
namespace Magento\PageBuilder\Model\Config\ContentTypes;
9+
namespace Magento\PageBuilder\Model\Config\ContentType;
1010

1111
class Reader extends \Magento\Framework\Config\Reader\Filesystem
1212
{
@@ -24,18 +24,18 @@ class Reader extends \Magento\Framework\Config\Reader\Filesystem
2424
self::TYPE_PATH . '/appearances/appearance/data' => 'name',
2525
self::TYPE_PATH . '/appearances/appearance/data_mapping/elements/element' => 'name',
2626
self::TYPE_PATH . '/appearances/appearance/data_mapping/elements/element/style_properties/property'
27-
=> 'var',
27+
=> 'name',
2828
self::TYPE_PATH . '/appearances/appearance/data_mapping/elements/element/style_properties/complex_property'
29-
=> 'var',
30-
self::TYPE_PATH . '/appearances/appearance/data_mapping/elements/element/style_properties/static_property'
3129
=> 'name',
30+
self::TYPE_PATH . '/appearances/appearance/data_mapping/elements/element/style_properties/static_property'
31+
=> 'source',
3232
self::TYPE_PATH . '/additional_data/arguments' => 'name',
33-
self::TYPE_PATH . '/appearances/appearance/data_mapping/elements/element/attributes/attribute' => 'var',
33+
self::TYPE_PATH . '/appearances/appearance/data_mapping/elements/element/attributes/attribute' => 'name',
3434
self::TYPE_PATH . '/appearances/appearance/data_mapping/elements/element/attributes/complex_attribute'
35-
=> 'var',
36-
self::TYPE_PATH . '/appearances/appearance/data_mapping/elements/element/attributes/static_attribute'
3735
=> 'name',
38-
self::TYPE_PATH . '/appearances/appearance/data_mapping/elements/element/css/filter/class' => 'name',
36+
self::TYPE_PATH . '/appearances/appearance/data_mapping/elements/element/attributes/static_attribute'
37+
=> 'source',
38+
self::TYPE_PATH . '/appearances/appearance/data_mapping/elements/element/css/filter/class' => 'source',
3939
self::TYPE_PATH . '/appearances/appearance/data_mapping/converters/converter' => 'name',
4040
self::TYPE_PATH . '/appearances/appearance/data_mapping/converters/converter/config/item' => 'name',
4141
self::TYPE_PATH . '/appearances/appearance/readers/reader' => 'name'
@@ -44,24 +44,24 @@ class Reader extends \Magento\Framework\Config\Reader\Filesystem
4444
/**
4545
* Constructor
4646
*
47-
* @param \Magento\PageBuilder\Model\Config\ContentTypes\FileResolver $fileResolver
48-
* @param \Magento\PageBuilder\Model\Config\ContentTypes\Converter $converter
49-
* @param \Magento\PageBuilder\Model\Config\ContentTypes\SchemaLocator $schemaLocator
47+
* @param \Magento\PageBuilder\Model\Config\FileResolver $fileResolver
48+
* @param \Magento\PageBuilder\Model\Config\ContentType\Converter $converter
49+
* @param \Magento\PageBuilder\Model\Config\ContentType\SchemaLocator $schemaLocator
5050
* @param \Magento\Framework\Config\ValidationStateInterface $validationState
5151
* @param string $fileName
5252
* @param array $idAttributes
5353
* @param string $domDocumentClass
5454
* @param string $defaultScope
5555
*/
5656
public function __construct(
57-
\Magento\PageBuilder\Model\Config\ContentTypes\FileResolver $fileResolver,
58-
\Magento\PageBuilder\Model\Config\ContentTypes\Converter $converter,
59-
\Magento\PageBuilder\Model\Config\ContentTypes\SchemaLocator $schemaLocator,
57+
\Magento\PageBuilder\Model\Config\FileResolver $fileResolver,
58+
\Magento\PageBuilder\Model\Config\ContentType\Converter $converter,
59+
\Magento\PageBuilder\Model\Config\ContentType\SchemaLocator $schemaLocator,
6060
\Magento\Framework\Config\ValidationStateInterface $validationState,
61-
string $fileName = '*.xml',
61+
string $fileName = 'content_type/*.xml',
6262
array $idAttributes = [],
6363
string $domDocumentClass = \Magento\Framework\Config\Dom::class,
64-
string $defaultScope = 'content_types'
64+
string $defaultScope = 'global'
6565
) {
6666
parent::__construct(
6767
$fileResolver,

app/code/Magento/PageBuilder/Model/Config/ContentTypes/SchemaLocator.php renamed to app/code/Magento/PageBuilder/Model/Config/ContentType/SchemaLocator.php

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

77
declare(strict_types=1);
88

9-
namespace Magento\PageBuilder\Model\Config\ContentTypes;
9+
namespace Magento\PageBuilder\Model\Config\ContentType;
1010

1111
class SchemaLocator implements \Magento\Framework\Config\SchemaLocatorInterface
1212
{
@@ -31,8 +31,8 @@ public function __construct(
3131
\Magento\Framework\Module\Dir\Reader $moduleReader
3232
) {
3333
$etcDir = $moduleReader->getModuleDir('etc', 'Magento_PageBuilder');
34-
$this->schema = $etcDir . DIRECTORY_SEPARATOR . 'content_types.xsd';
35-
$this->perFileSchema = $etcDir . DIRECTORY_SEPARATOR . 'content_types.xsd';
34+
$this->schema = $etcDir . DIRECTORY_SEPARATOR . 'content_type_merged.xsd';
35+
$this->perFileSchema = $etcDir . DIRECTORY_SEPARATOR . 'content_type.xsd';
3636
}
3737

3838
/**

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

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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;
10+
11+
use Magento\Framework\View\File\CollectorInterface;
12+
use Magento\Framework\View\DesignInterface;
13+
use Magento\Framework\Filesystem\Directory\ReadFactory;
14+
15+
class FileResolver implements \Magento\Framework\Config\FileResolverInterface
16+
{
17+
/**
18+
* @var CollectorInterface
19+
*/
20+
private $baseFiles;
21+
22+
/**
23+
* @var DesignInterface
24+
*/
25+
private $design;
26+
27+
/**
28+
* @var ReadFactory
29+
*/
30+
private $readFactory;
31+
32+
/**
33+
* @param CollectorInterface $baseFiles
34+
* @param DesignInterface $design
35+
* @param ReadFactory $readFactory
36+
*/
37+
public function __construct(
38+
CollectorInterface $baseFiles,
39+
DesignInterface $design,
40+
ReadFactory $readFactory
41+
) {
42+
$this->baseFiles = $baseFiles;
43+
$this->design = $design;
44+
$this->readFactory = $readFactory;
45+
}
46+
47+
/**
48+
* {@inheritdoc}
49+
*/
50+
public function get($filename, $scope): array
51+
{
52+
$result = [];
53+
54+
$files = $this->baseFiles->getFiles($this->design->getDesignTheme(), $filename);
55+
foreach ($files as $file) {
56+
$fullFileName = $file->getFileName();
57+
$fileDir = dirname($fullFileName);
58+
$fileName = basename($fullFileName);
59+
$dirRead = $this->readFactory->create($fileDir);
60+
$result[$fullFileName] = $dirRead->readFile($fileName);
61+
}
62+
return $result;
63+
}
64+
}

0 commit comments

Comments
 (0)