Skip to content

Commit aa3831d

Browse files
committed
Merge remote-tracking branch 'mainline/develop' into MAGETWO-90473-add-missing-tests-for-buttons
2 parents 5778f09 + 1512701 commit aa3831d

File tree

182 files changed

+5439
-2347
lines changed

Some content is hidden

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

182 files changed

+5439
-2347
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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\ContentType\Products;
10+
11+
use Magento\Backend\Block\Template;
12+
13+
/**
14+
* The block used to render the conditions rule tree form within the PageBuilder interface.
15+
*/
16+
class Conditions extends Template
17+
{
18+
/**
19+
*
20+
* @var string
21+
*/
22+
protected $_template = 'Magento_PageBuilder::content_type/products/conditions.phtml';
23+
24+
/**
25+
* @var \Magento\Framework\Serialize\Serializer\Json
26+
*/
27+
private $serializer;
28+
29+
/**
30+
* Conditions constructor.
31+
* @param Template\Context $context
32+
* @param \Magento\Framework\Serialize\Serializer\Json $serializer
33+
* @param array $data
34+
*/
35+
public function __construct(
36+
\Magento\Backend\Block\Template\Context $context,
37+
\Magento\Framework\Serialize\Serializer\Json $serializer,
38+
array $data = []
39+
) {
40+
$this->serializer = $serializer;
41+
parent::__construct($context, $data);
42+
}
43+
44+
/**
45+
* Returns the form namespace to be used with the JS config
46+
*
47+
* @return string
48+
*/
49+
public function getFormNamespace(): string
50+
{
51+
return 'pagebuilder_products_form';
52+
}
53+
54+
/**
55+
* Returns an array of arguments to pass to the condition tree UIComponent
56+
*
57+
* @return array
58+
*/
59+
private function getConfig(): array
60+
{
61+
return [
62+
'formNamespace' => $this->getFormNamespace(),
63+
'componentUrl' => $this->getUrl(
64+
'pagebuilder/contenttype/products_conditions',
65+
['form_namespace' => $this->getFormNamespace()]
66+
),
67+
'jsObjectName' => $this->getFormNamespace(),
68+
'childComponentUrl' => $this->getUrl(
69+
'pagebuilder/contenttype/products_conditions_child',
70+
['form_namespace' => $this->getFormNamespace()]
71+
),
72+
];
73+
}
74+
75+
public function getConfigJson(): string
76+
{
77+
return $this->serializer->serialize([
78+
'[data-role=pagebuilder-product-conditions-form-placeholder]' => [
79+
'Magento_PageBuilder/js/content-type/products/conditions-loader' => $this->getConfig(),
80+
]
81+
]);
82+
}
83+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\PageBuilder\Block\Adminhtml\System\Config\Form\Field;
9+
10+
class GoogleMapsApiKey extends \Magento\Config\Block\System\Config\Form\Field
11+
{
12+
/**
13+
* @inheritdoc
14+
*/
15+
protected function _prepareLayout()
16+
{
17+
parent::_prepareLayout();
18+
$this->setTemplate('Magento_PageBuilder::system/config/google_maps_api_key.phtml');
19+
return $this;
20+
}
21+
22+
/**
23+
* @inheritdoc
24+
*/
25+
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
26+
{
27+
$element = clone $element;
28+
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
29+
return parent::render($element);
30+
}
31+
32+
/**
33+
* @inheritdoc
34+
*/
35+
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
36+
{
37+
$originalData = $element->getOriginalData();
38+
$this->addData(
39+
[
40+
'button_label' => __($originalData['button_label']),
41+
'valid_label' => __($originalData['valid_label']),
42+
'invalid_label' => __($originalData['invalid_label']),
43+
'source_field' => $originalData['source_field'],
44+
'html_id' => $element->getHtmlId(),
45+
'validate_url' => $this->_urlBuilder->getUrl('pagebuilder/googlemaps/validateapi')
46+
]
47+
);
48+
49+
return $this->_toHtml();
50+
}
51+
}

app/code/Magento/PageBuilder/Block/ContentType/Product.php

Lines changed: 0 additions & 67 deletions
This file was deleted.

app/code/Magento/PageBuilder/Block/ContentType/ProductList.php

Lines changed: 0 additions & 111 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\PageBuilder\Block;
9+
10+
/**
11+
* @api
12+
*/
13+
class GoogleMapsApiBlock extends \Magento\Framework\View\Element\Template
14+
{
15+
const GOOGLE_MAPS_API_KEY_PATH = 'cms/pagebuilder/google_maps_api_key';
16+
const GOOGLE_MAPS_LIBRARY_URL = 'https://maps.googleapis.com/maps/api/js?v=3&key=%s';
17+
18+
/**
19+
* Generate URL for retrieving Google Maps Javascript API
20+
*
21+
* @return string
22+
*/
23+
public function getGoogleMapsApiPath(): string
24+
{
25+
$apiKey = $this->_scopeConfig->getValue(self::GOOGLE_MAPS_API_KEY_PATH);
26+
$libraryUrlWithKey = sprintf(self::GOOGLE_MAPS_LIBRARY_URL, $apiKey);
27+
return $libraryUrlWithKey;
28+
}
29+
}

0 commit comments

Comments
 (0)