Skip to content

Commit

Permalink
Remove SecureHtmlRenderer that does not exists in Magento 2.3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ihorvansach committed Jun 29, 2022
1 parent eb74985 commit 4841841
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Magento\Framework\Data\Form\Element\Factory;
use Magento\Framework\Escaper;
use Magento\Framework\Math\Random;
use Magento\Framework\View\Helper\SecureHtmlRenderer;
use Magefan\Blog\Block\Adminhtml\System\Config\Form\Featured\Grid;
use Magento\Framework\View\LayoutFactory;

Expand All @@ -28,20 +27,16 @@ class GridElement extends \Magento\Framework\Data\Form\Element\AbstractElement
* @param Escaper $escaper
* @param LayoutFactory $layoutFactory
* @param array $data
* @param SecureHtmlRenderer|null $secureRenderer
* @param Random|null $random
*/
public function __construct(
Factory $factoryElement,
CollectionFactory $factoryCollection,
Escaper $escaper,
LayoutFactory $layoutFactory,
array $data = [],
?SecureHtmlRenderer $secureRenderer = null,
?Random $random = null
array $data = []
) {
$this->layoutFactory = $layoutFactory;
parent::__construct($factoryElement, $factoryCollection, $escaper, $data, $secureRenderer, $random);
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
}

/**
Expand Down
36 changes: 3 additions & 33 deletions Block/Adminhtml/Widget/Featured/Grid/Chooser.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,15 @@

namespace Magefan\Blog\Block\Adminhtml\Widget\Featured\Grid;

use Magento\Framework\App\ObjectManager;
use Magento\Framework\View\Helper\SecureHtmlRenderer;

class Chooser extends \Magento\Widget\Block\Adminhtml\Widget\Chooser
{
/**
* @var SecureHtmlRenderer|null
*/
protected $secureRenderer;

/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
* @param \Magento\Framework\Data\Form\Element\Factory $elementFactory
* @param array $data
* @param SecureHtmlRenderer|null $secureRenderer
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Json\EncoderInterface $jsonEncoder,
\Magento\Framework\Data\Form\Element\Factory $elementFactory,
array $data = [], ?SecureHtmlRenderer
$secureRenderer = null
) {
$this->secureRenderer = $secureRenderer ?? ObjectManager::getInstance()->get(SecureHtmlRenderer::class);
parent::__construct($context, $jsonEncoder, $elementFactory, $data, $secureRenderer);
}

/**
* @param string $chooserId
* @return string
*/
public function onClickJs(string $chooserId) : string
{
$buttonHtml = "<button id='addBtn' class='action-primary' ><span>Save</span></button>";
$buttonHtml = "<button id='addBtn' class='action-primary' ><span>Use Selected Posts</span></button>";
$js = '
var waitForElm = function(selector) {
return new Promise(resolve => {
Expand Down Expand Up @@ -203,9 +177,7 @@ protected function _toHtml() : string
<div id="' .
$chooserId .
'advice-container" class="hidden"></div>' .
$this->secureRenderer->renderTag(
'script',
[],
'<script>' .
'require(["prototype", "mage/adminhtml/wysiwyg/widget"], function(){
//<![CDATA[
(function() {
Expand Down Expand Up @@ -239,8 +211,6 @@ protected function _toHtml() : string
})();
//]]>
});
',
false
);
' . '</script>';
}
}

0 comments on commit 4841841

Please sign in to comment.