Skip to content

Commit 5318032

Browse files
committed
#544: Configurable Page Builder Full Screen Mode
- Adding `isContentPreviewEnabled()` Method - Updating Instances of WYSIWYG Config Data
1 parent a55d8b4 commit 5318032

File tree

3 files changed

+49
-5
lines changed

3 files changed

+49
-5
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class Config extends \Magento\Framework\Config\Data implements \Magento\PageBuil
1717
{
1818
const IS_PAGEBUILDER_ENABLED = 'cms/pagebuilder/enabled';
1919

20+
private const IS_PAGEBUILDER_CONTENT_PREVIEW_ENABLED = 'cms/pagebuilder/enable_content_preview';
21+
2022
/**
2123
* @var ScopeConfigInterface
2224
*/
@@ -69,4 +71,16 @@ public function isEnabled(): bool
6971
\Magento\PageBuilder\Model\Config::IS_PAGEBUILDER_ENABLED
7072
);
7173
}
74+
75+
/**
76+
* Returns Configuration Setting for Page Builder Content Preview
77+
*
78+
* @return bool
79+
*/
80+
public function isContentPreviewEnabled(): bool
81+
{
82+
return (bool) $this->scopeConfig->getValue(
83+
\Magento\PageBuilder\Model\Config::IS_PAGEBUILDER_CONTENT_PREVIEW_ENABLED
84+
);
85+
}
7286
}

app/code/Magento/PageBuilder/Plugin/Catalog/Ui/DataProvider/Product/Form/Modifier/EavPlugin.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Catalog\Api\Data\ProductAttributeInterface;
1212
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav as EavModifier;
1313
use Magento\Framework\Stdlib\ArrayManager;
14+
use Magento\PageBuilder\Model\Config;
1415

1516
/**
1617
* Data Provider for EAV Attributes on Product Page
@@ -24,12 +25,21 @@ class EavPlugin
2425
*/
2526
private $arrayManager;
2627

28+
/**
29+
* @var Config
30+
*/
31+
private $config;
32+
2733
/**
2834
* @param ArrayManager $arrayManager
35+
* @param Config $config
2936
*/
30-
public function __construct(ArrayManager $arrayManager)
31-
{
37+
public function __construct(
38+
ArrayManager $arrayManager,
39+
Config $config
40+
) {
3241
$this->arrayManager = $arrayManager;
42+
$this->config = $config;
3343
}
3444

3545
/**
@@ -53,7 +63,7 @@ public function afterSetupAttributeMeta(
5363
) {
5464
$meta = $result;
5565

56-
if ($attribute->getData('is_pagebuilder_enabled')) {
66+
if ($this->config->isContentPreviewEnabled() && $attribute->getData('is_pagebuilder_enabled')) {
5767
$meta = $this->arrayManager->merge(
5868
static::META_ATTRIBUTE_CONFIG_PATH,
5969
$result,
@@ -83,7 +93,7 @@ public function afterSetupAttributeContainerMeta(
8393
) {
8494
$containerMeta = $result;
8595

86-
if ($attribute->getData('is_pagebuilder_enabled')) {
96+
if ($this->config->isContentPreviewEnabled() && $attribute->getData('is_pagebuilder_enabled')) {
8797
$containerMeta = $this->arrayManager->merge(
8898
static::META_ATTRIBUTE_CONFIG_PATH,
8999
$result,

app/code/Magento/PageBuilder/Ui/DataProvider/Product/Form/Modifier/Eav/WysiwygConfigDataProcessor.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,42 @@
88

99
namespace Magento\PageBuilder\Ui\DataProvider\Product\Form\Modifier\Eav;
1010

11+
use Magento\Framework\App\ObjectManager;
12+
use Magento\PageBuilder\Model\Config;
13+
1114
class WysiwygConfigDataProcessor implements
1215
\Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav\WysiwygConfigDataProcessorInterface
1316
{
17+
/**
18+
* @var Config
19+
*/
20+
private $config;
21+
22+
/**
23+
* @param Config|null $config
24+
*/
25+
public function __construct(
26+
Config $config = null
27+
) {
28+
$this->config = $config ?: ObjectManager::getInstance()->get(Config::class);
29+
}
30+
1431
/**
1532
* @inheritdoc
1633
*/
1734
public function process(\Magento\Catalog\Api\Data\ProductAttributeInterface $attribute)
1835
{
36+
$isContentPreviewEnabled = $this->config->isContentPreviewEnabled();
1937
$wysiwygConfigData = [];
38+
2039
if ($attribute->getData('is_pagebuilder_enabled')) {
2140
$wysiwygConfigData['is_pagebuilder_enabled'] = true;
22-
$wysiwygConfigData['pagebuilder_content_snapshot'] = true;
41+
$wysiwygConfigData['pagebuilder_content_snapshot'] = $isContentPreviewEnabled;
2342
$wysiwygConfigData['pagebuilder_button'] = true;
2443
} else {
2544
$wysiwygConfigData['is_pagebuilder_enabled'] = false;
2645
}
46+
2747
return $wysiwygConfigData;
2848
}
2949
}

0 commit comments

Comments
 (0)