6 declare(strict_types=1);
52 private $directivePatterns;
66 \
Magento\Framework\Escaper $escaper,
67 $directivePatterns = []
70 $this->_catalogData = $catalogData;
71 $this->_escaper = $escaper;
72 $this->directivePatterns = $directivePatterns;
73 parent::__construct($context);
81 if (
null === $this->_templateProcessor) {
82 $this->_templateProcessor = $this->_catalogData->getPageTemplateProcessor();
102 if (!isset($this->_handlers[
$method])) {
103 $this->_handlers[
$method] = [];
119 return $this->_handlers[
$method] ?? [];
152 $attribute = $this->_eavConfig->getAttribute(ModelProduct::ENTITY, $attributeName);
155 $attribute->getFrontendInput() !=
'media_image' &&
159 if (
$attribute->getFrontendInput() !=
'price') {
160 $attributeHtml = $this->_escaper->escapeHtml($attributeHtml);
162 if (
$attribute->getFrontendInput() ==
'textarea') {
163 $attributeHtml = nl2br($attributeHtml);
166 if ($attributeHtml !==
null 169 && $this->isDirectivesExists($attributeHtml)
171 $attributeHtml = $this->_getTemplateProcessor()->filter($attributeHtml);
174 $attributeHtml = $this->process(
177 [
'product' =>
$product,
'attribute' => $attributeName]
180 return $attributeHtml;
194 $attribute = $this->_eavConfig->getAttribute(ModelCategory::ENTITY, $attributeName);
201 $attributeHtml = $this->_escaper->escapeHtml($attributeHtml);
203 if ($attributeHtml !==
null 206 && $this->isDirectivesExists($attributeHtml)
209 $attributeHtml = $this->_getTemplateProcessor()->filter($attributeHtml);
211 $attributeHtml = $this->process(
214 [
'category' =>
$category,
'attribute' => $attributeName]
216 return $attributeHtml;
228 foreach ($this->directivePatterns as
$pattern) {
229 if (preg_match(
$pattern, $attributeHtml)) {
__construct(\Magento\Framework\App\Helper\Context $context, \Magento\Eav\Model\Config $eavConfig, Data $catalogData, \Magento\Framework\Escaper $escaper, $directivePatterns=[])
process($method, $result, $params)
addHandler($method, $handler)
categoryAttribute($category, $attributeHtml, $attributeName)
productAttribute($product, $attributeHtml, $attributeName)
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
isDirectivesExists($attributeHtml)
catch(\Exception $e) $handler