Skip to content

Commit e101dfb

Browse files
Merge branch '1.1-develop' of github.com:magento/magento2-page-builder into PB-156
2 parents 80b7425 + 3010f49 commit e101dfb

File tree

221 files changed

+6470
-2249
lines changed

Some content is hidden

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

221 files changed

+6470
-2249
lines changed

app/code/Magento/CatalogPageBuilderAnalytics/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"magento/module-page-builder-analytics": "*",
99
"magento/module-catalog": "*",
1010
"magento/framework": "*",
11-
"php": "~7.1.3||~7.2.0"
11+
"php": "~7.1.3||~7.2.0||~7.3.0"
1212
},
1313
"type": "magento2-module",
1414
"license": [

app/code/Magento/CmsPageBuilderAnalytics/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"magento/module-page-builder-analytics": "*",
99
"magento/module-cms": "*",
1010
"magento/framework": "*",
11-
"php": "~7.1.3||~7.2.0"
11+
"php": "~7.1.3||~7.2.0||~7.3.0"
1212
},
1313
"type": "magento2-module",
1414
"license": [
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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\Block\Adminhtml\Stage;
10+
11+
use Magento\Framework\View\Element\Template;
12+
use Magento\RequireJs\Model\FileManager;
13+
use Magento\PageBuilder\Model\Stage\Config;
14+
use Magento\Framework\Serialize\Serializer\Json;
15+
16+
/**
17+
* Class Render
18+
*/
19+
class Render extends Template
20+
{
21+
/**
22+
* @var FileManager
23+
*/
24+
private $fileManager;
25+
26+
/**
27+
* @var Config
28+
*/
29+
private $pageBuilderConfig;
30+
31+
/**
32+
* @var Json
33+
*/
34+
private $json;
35+
36+
/**
37+
* @param Template\Context $context
38+
* @param FileManager $fileManager
39+
* @param Config $config
40+
* @param Json $json
41+
* @param array $data
42+
*/
43+
public function __construct(
44+
Template\Context $context,
45+
FileManager $fileManager,
46+
Config $config,
47+
Json $json,
48+
array $data = []
49+
) {
50+
parent::__construct($context, $data);
51+
$this->fileManager = $fileManager;
52+
$this->pageBuilderConfig = $config;
53+
$this->json = $json;
54+
}
55+
56+
/**
57+
* Generate the URL to RequireJS
58+
*
59+
* @return string
60+
* @throws \Magento\Framework\Exception\LocalizedException
61+
*/
62+
public function getRequireJsUrl() : string
63+
{
64+
$asset = $this->_assetRepo->createAsset('requirejs/require.js');
65+
return $asset->getUrl();
66+
}
67+
68+
/**
69+
* Retrieve the URL to the RequireJS Config file
70+
*
71+
* @return string
72+
*/
73+
public function getRequireJsConfigUrl() : string
74+
{
75+
$requireJsConfig = $this->fileManager->createRequireJsConfigAsset();
76+
return $requireJsConfig->getUrl();
77+
}
78+
79+
/**
80+
* Retrieve the Page Builder's config
81+
*
82+
* @return array
83+
*/
84+
public function getPageBuilderConfig() : string
85+
{
86+
return $this->json->serialize($this->pageBuilderConfig->getConfig());
87+
}
88+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\PageBuilder\Component\Form;
8+
9+
use Magento\Backend\Model\UrlInterface as BackendUrlInterface;
10+
use Magento\Cms\Helper\Wysiwyg\Images;
11+
use Magento\Framework\View\Element\UiComponentFactory;
12+
use Magento\Framework\View\Element\UiComponent\ContextInterface;
13+
use Magento\Variable\Model\Variable\Config as VariableConfig;
14+
15+
/**
16+
* Updates field element with HTML Code specific config
17+
*/
18+
class HtmlCode extends \Magento\Ui\Component\Form\Field
19+
{
20+
const HTML_ID_PLACEHOLDER = 'HTML_ID_PLACEHOLDER';
21+
22+
/**
23+
* @var BackendUrlInterface
24+
*/
25+
private $backendUrl;
26+
27+
/**
28+
* @var Images
29+
*/
30+
private $imagesHelper;
31+
32+
/**
33+
* @var VariableConfig
34+
*/
35+
private $variableConfig;
36+
37+
/**
38+
* @var string
39+
*/
40+
private $currentTreePath;
41+
42+
/**
43+
* @param ContextInterface $context
44+
* @param UiComponentFactory $uiComponentFactory
45+
* @param BackendUrlInterface $backendUrl
46+
* @param Images $imagesHelper
47+
* @param VariableConfig $variableConfig
48+
* @param string $currentTreePath
49+
* @param array $components
50+
* @param array $data
51+
*/
52+
public function __construct(
53+
ContextInterface $context,
54+
UiComponentFactory $uiComponentFactory,
55+
BackendUrlInterface $backendUrl,
56+
Images $imagesHelper,
57+
VariableConfig $variableConfig,
58+
$currentTreePath = 'wysiwyg',
59+
$components = [],
60+
array $data = []
61+
) {
62+
$this->backendUrl = $backendUrl;
63+
$this->imagesHelper = $imagesHelper;
64+
$this->variableConfig = $variableConfig;
65+
$this->currentTreePath = $currentTreePath;
66+
parent::__construct($context, $uiComponentFactory, $components, $data);
67+
}
68+
69+
/**
70+
* Prepare component configuration
71+
*
72+
* @return void
73+
* @throws \Magento\Framework\Exception\LocalizedException
74+
*/
75+
public function prepare()
76+
{
77+
$config = $this->getData('config');
78+
$config['widgetUrl'] = $this->backendUrl->getUrl(
79+
'adminhtml/widget/index',
80+
[
81+
'widget_target_id' => self::HTML_ID_PLACEHOLDER
82+
]
83+
);
84+
$config['imageUrl'] = $this->backendUrl->getUrl(
85+
'cms/wysiwyg_images/index',
86+
[
87+
'current_tree_path' => $this->imagesHelper->idEncode($this->currentTreePath),
88+
'target_element_id' => self::HTML_ID_PLACEHOLDER
89+
]
90+
);
91+
$config['variableUrl'] = $this->variableConfig->getVariablesWysiwygActionUrl();
92+
$this->setData('config', $config);
93+
parent::prepare();
94+
}
95+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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\Controller\Adminhtml\Stage;
10+
11+
use Magento\Framework\Controller\ResultFactory;
12+
use Magento\Framework\App\Action\HttpPostActionInterface;
13+
14+
/**
15+
* Preview controller to render blocks preview on Stage
16+
*/
17+
class Preview extends \Magento\Backend\App\Action implements HttpPostActionInterface
18+
{
19+
const ADMIN_RESOURCE = 'Magento_Backend::content';
20+
21+
/**
22+
* @var \Magento\PageBuilder\Model\Stage\RendererPool
23+
*/
24+
private $rendererPool;
25+
26+
/**
27+
* @var \Magento\PageBuilder\Model\Stage\Preview
28+
*/
29+
private $preview;
30+
31+
/**
32+
* @param \Magento\Backend\App\Action\Context $context
33+
* @param \Magento\PageBuilder\Model\Stage\RendererPool $rendererPool
34+
* @param \Magento\PageBuilder\Model\Stage\Preview $preview
35+
*/
36+
public function __construct(
37+
\Magento\Backend\App\Action\Context $context,
38+
\Magento\PageBuilder\Model\Stage\RendererPool $rendererPool,
39+
\Magento\PageBuilder\Model\Stage\Preview $preview
40+
) {
41+
parent::__construct($context);
42+
43+
$this->rendererPool = $rendererPool;
44+
$this->preview = $preview;
45+
}
46+
47+
/**
48+
* Generates an HTML preview for the stage
49+
*
50+
* @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|mixed
51+
* @throws \Exception
52+
*/
53+
public function execute()
54+
{
55+
return $this->preview->startPreviewMode(
56+
function () {
57+
$pageResult = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
58+
// Some template filters and directive processors expect this to be called in order to function.
59+
$pageResult->initLayout();
60+
61+
$params = $this->getRequest()->getParams();
62+
$renderer = $this->rendererPool->getRenderer($params['role']);
63+
$result = ['data' => $renderer->render($params)];
64+
65+
return $this->resultFactory->create(ResultFactory::TYPE_JSON)->setData($result);
66+
}
67+
);
68+
}
69+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
*
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
8+
namespace Magento\PageBuilder\Controller\Adminhtml\Stage;
9+
10+
use Magento\Framework\App\Action\HttpGetActionInterface;
11+
use Magento\RequireJs\Block\Html\Head\Config;
12+
13+
/**
14+
* Class Render
15+
*
16+
* Iframe to render Page Builder stage in isolation
17+
*/
18+
class Render extends \Magento\Backend\App\Action implements HttpGetActionInterface
19+
{
20+
const ADMIN_RESOURCE = 'Magento_Backend::content';
21+
22+
/**
23+
* Render the RequireJS and Page Builder render blocks without any additional layout
24+
*
25+
* @return void
26+
*/
27+
public function execute()
28+
{
29+
$layout = $this->_view->getLayout();
30+
$requireJs = $layout->createBlock(
31+
\Magento\Backend\Block\Page\RequireJs::class,
32+
'require.js'
33+
);
34+
$requireJs->setTemplate('Magento_Backend::page/js/require_js.phtml');
35+
/* @var \Magento\PageBuilder\Block\Adminhtml\Stage\Render $renderBlock */
36+
$renderBlock = $layout->createBlock(
37+
\Magento\PageBuilder\Block\Adminhtml\Stage\Render::class,
38+
'stage_render'
39+
);
40+
$renderBlock->setTemplate('Magento_PageBuilder::stage/render.phtml');
41+
$babelPolyfill = $layout->createBlock(
42+
\Magento\PageBuilder\Block\Adminhtml\Html\Head\BabelPolyfill::class,
43+
'pagebuilder.babel.polyfill'
44+
);
45+
$babelPolyfill->setTemplate('Magento_PageBuilder::html/head/babel_polyfill.phtml');
46+
$this->getResponse()->setBody($requireJs->toHtml() . $babelPolyfill->toHtml() . $renderBlock->toHtml());
47+
$this->getResponse()->sendResponse();
48+
}
49+
}

app/code/Magento/PageBuilder/Controller/ContentType/Preview.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* This isn't placed within the adminhtml folder as it has to extend from the front-end controllers app action to
1818
* ensure the content is rendered in the storefront scope.
1919
*
20+
* @deprecated use \Magento\PageBuilder\Controller\Adminhtml\Stage\Preview
21+
*
2022
* @api
2123
*/
2224
class Preview extends \Magento\Framework\App\Action\Action implements HttpPostActionInterface

0 commit comments

Comments
 (0)