diff --git a/Block/Adminhtml/Template/Preview.php b/Block/Adminhtml/Template/Preview.php
index d2fdcb8e315fe..b9f090a69adac 100644
--- a/Block/Adminhtml/Template/Preview.php
+++ b/Block/Adminhtml/Template/Preview.php
@@ -15,6 +15,11 @@
*/
class Preview extends \Magento\Backend\Block\Widget
{
+ /**
+ * @var string
+ */
+ private const ADMIN_RESOURCE = 'Magento_Email::template';
+
/**
* @var \Magento\Framework\Filter\Input\MaliciousCode
*/
@@ -55,6 +60,10 @@ public function __construct(
*/
protected function _toHtml()
{
+ if (!$this->_authorization->isAllowed(self::ADMIN_RESOURCE)) {
+ return '';
+ }
+
$request = $this->getRequest();
$storeId = $this->getAnyStoreView()->getId();
diff --git a/Model/AbstractTemplate.php b/Model/AbstractTemplate.php
index 7c5c973c60555..7e1456859ddfe 100644
--- a/Model/AbstractTemplate.php
+++ b/Model/AbstractTemplate.php
@@ -761,6 +761,32 @@ public function getUrl(Store $store, $route = '', $params = [])
return $url->getUrl($route, $params);
}
+ /**
+ * Set template text
+ *
+ * Rejects non-string input
+ *
+ * @param mixed $value
+ * @return $this
+ */
+ public function setTemplateText($value)
+ {
+ return $this->setData('template_text', is_string($value) ? $value : '');
+ }
+
+ /**
+ * Set template styles
+ *
+ * Rejects non-string input
+ *
+ * @param mixed $value
+ * @return $this
+ */
+ public function setTemplateStyles($value)
+ {
+ return $this->setData('template_styles', is_string($value) ? $value : '');
+ }
+
/**
* Validate template code
*