Skip to content

Commit 94a09da

Browse files
committed
Merge remote-tracking branch 'owls/PB-173' into PB-107
2 parents 9ed871e + 89d1c75 commit 94a09da

File tree

68 files changed

+8112
-1465
lines changed

Some content is hidden

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

68 files changed

+8112
-1465
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,22 @@ public function __construct(
4747

4848
/**
4949
* Returns config for widgets initializer component.
50+
*
5051
* @return string
5152
* @api
5253
*/
5354
public function getConfig() : string
5455
{
5556
return $this->jsonSerializer->serialize($this->config->getConfig());
5657
}
58+
59+
/**
60+
* Returns breakpoints for widgets initializer component.
61+
*
62+
* @return string
63+
*/
64+
public function getBreakpoints() : string
65+
{
66+
return $this->jsonSerializer->serialize($this->config->getBreakpoints());
67+
}
5768
}

app/code/Magento/PageBuilder/Model/Filter/Template.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,13 @@ private function generateCssFromImages(string $elementClass, array $images) : st
272272
'background-image' => 'url(' . $images['desktop_image'] . ')',
273273
];
274274
}
275-
if (isset($images['mobile_image']) && $this->getMobileMediaQuery()) {
276-
$css[$this->getMobileMediaQuery()]['.' . $elementClass] = [
275+
if (isset($images['mobile_image']) && $this->getMediaQuery('mobile')) {
276+
$css[$this->getMediaQuery('mobile')]['.' . $elementClass] = [
277+
'background-image' => 'url(' . $images['mobile_image'] . ')',
278+
];
279+
}
280+
if (isset($images['mobile_image']) && $this->getMediaQuery('mobile-small')) {
281+
$css[$this->getMediaQuery('mobile-small')]['.' . $elementClass] = [
277282
'background-image' => 'url(' . $images['mobile_image'] . ')',
278283
];
279284
}
@@ -305,13 +310,14 @@ private function cssFromArray(array $css) : string
305310
/**
306311
* Generate the mobile media query from view configuration
307312
*
313+
* @param string $view
308314
* @return null|string
309315
*/
310-
private function getMobileMediaQuery() : ?string
316+
private function getMediaQuery(string $view) : ?string
311317
{
312318
$breakpoints = $this->viewConfig->getViewConfig()->getVarValue(
313319
'Magento_PageBuilder',
314-
'breakpoints/mobile/conditions'
320+
'breakpoints/' . $view . '/conditions'
315321
);
316322
if ($breakpoints && count($breakpoints) > 0) {
317323
$mobileBreakpoint = '@media only screen ';

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ public function getConfig()
141141
'column_grid_max' => $this->scopeConfig->getValue(self::XML_PATH_COLUMN_GRID_MAX),
142142
'can_use_inline_editing_on_stage' => $this->isWysiwygProvisionedForEditingOnStage(),
143143
'widgets' => $this->widgetInitializerConfig->getConfig(),
144+
'breakpoints' => $this->widgetInitializerConfig->getBreakpoints()
144145
];
145146
}
146147

@@ -190,13 +191,15 @@ private function getContentTypes()
190191
*/
191192
private function flattenContentTypeData(string $name, array $contentType)
192193
{
193-
return [
194+
$result = [
194195
'name' => $name,
195196
'label' => $contentType['label'],
196197
'icon' => isset($contentType['icon']) ? $contentType['icon'] : '',
197198
'form' => isset($contentType['form']) ? $contentType['form'] : '',
198199
'menu_section' => $contentType['menu_section'] ?? 'general',
199-
'fields' => isset($contentType['form']) ? $this->uiComponentConfig->getFields($contentType['form']) : [],
200+
'fields' => isset($contentType['form'])
201+
? ['default' => $this->uiComponentConfig->getFields($contentType['form'])]
202+
: [],
200203
'component' => $contentType['component'],
201204
'preview_component' => $contentType['preview_component'] ?? self::DEFAULT_PREVIEW_COMPONENT,
202205
'master_component' => $contentType['master_component'] ?? self::DEFAULT_MASTER_COMPONENT,
@@ -207,6 +210,14 @@ private function flattenContentTypeData(string $name, array $contentType)
207210
: [],
208211
'is_system' => isset($contentType['is_system']) && $contentType['is_system'] === 'false' ? false : true
209212
];
213+
214+
foreach ($result['appearances'] as $key => $appearance) {
215+
if (isset($appearance['form'])) {
216+
$result['fields'][$key . '-appearance'] = $this->uiComponentConfig->getFields($appearance['form']);
217+
}
218+
}
219+
220+
return $result;
210221
}
211222

212223
/**

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ public function getFields($componentName) : array
4848
$componentConfig,
4949
function ($item, $key) {
5050
// Determine if this item has a formElement key
51-
if (isset($item[Converter::DATA_ARGUMENTS_KEY]['data']['config']['formElement'])) {
51+
if (isset($item[Converter::DATA_ARGUMENTS_KEY]['data']['config']['formElement'])
52+
&& !(isset($item[Converter::DATA_ARGUMENTS_KEY]['data']['config']['componentDisabled'])
53+
&& $item[Converter::DATA_ARGUMENTS_KEY]['data']['config']['componentDisabled'] === true)
54+
) {
5255
$elementConfig = $item[Converter::DATA_ARGUMENTS_KEY]['data']['config'];
5356
// If the field has a dataScope use that for the key instead of the name
5457
if (isset($elementConfig['dataScope'])) {

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

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
namespace Magento\PageBuilder\Model;
1010

11+
use Magento\Framework\App\ObjectManager;
12+
use Magento\Framework\View\ConfigInterface;
13+
1114
/**
1215
* Container for the configuration related to the widget initializer mechanism
1316
*/
@@ -18,12 +21,21 @@ class WidgetInitializerConfig
1821
*/
1922
private $config;
2023

24+
/**
25+
* @var ConfigInterface
26+
*/
27+
private $viewConfig;
28+
2129
/**
2230
* @param array $config
31+
* @param ConfigInterface|null $viewConfig
2332
*/
24-
public function __construct(array $config)
25-
{
33+
public function __construct(
34+
array $config,
35+
ConfigInterface $viewConfig = null
36+
) {
2637
$this->config = $config;
38+
$this->viewConfig = $viewConfig ?: ObjectManager::getInstance()->get(ConfigInterface::class);
2739
}
2840

2941
/**
@@ -43,10 +55,23 @@ public function getConfig(): array
4355
if (isset($item['appearance'])) {
4456
$selector .= sprintf('[data-appearance="%s"]', $item['appearance']);
4557
}
46-
$componentConfig = isset($item['config']) ? $item['config'] : '{}';
58+
$componentConfig = isset($item['config']) ? $item['config'] : false;
4759
$resultConfig[$selector][$item['component']] = $componentConfig;
4860
}
4961
}
5062
return $resultConfig;
5163
}
64+
65+
/**
66+
* Returns breakpoint for widgets initializer component.
67+
*
68+
* @return array
69+
*/
70+
public function getBreakpoints(): array
71+
{
72+
return $this->viewConfig->getViewConfig()->getVarValue(
73+
'Magento_PageBuilder',
74+
'breakpoints'
75+
);
76+
}
5277
}

0 commit comments

Comments
 (0)