diff --git a/app/code/Magento/Widget/Model/Template/Filter.php b/app/code/Magento/Widget/Model/Template/Filter.php index c79334f67a9c3..97e2d4fdcd775 100644 --- a/app/code/Magento/Widget/Model/Template/Filter.php +++ b/app/code/Magento/Widget/Model/Template/Filter.php @@ -22,21 +22,22 @@ class Filter extends \Magento\Cms\Model\Template\Filter protected $_widget; /** - * @param \Magento\Framework\Stdlib\StringUtils $string - * @param \Psr\Log\LoggerInterface $logger - * @param \Magento\Framework\Escaper $escaper - * @param \Magento\Framework\View\Asset\Repository $assetRepo + * @param \Magento\Framework\Stdlib\StringUtils $string + * @param \Psr\Log\LoggerInterface $logger + * @param \Magento\Framework\Escaper $escaper + * @param \Magento\Framework\View\Asset\Repository $assetRepo * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Variable\Model\VariableFactory $coreVariableFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\View\LayoutInterface $layout - * @param \Magento\Framework\View\LayoutFactory $layoutFactory - * @param \Magento\Framework\App\State $appState - * @param \Magento\Framework\UrlInterface $urlModel - * @param \Pelago\Emogrifier $emogrifier - * @param \Magento\Variable\Model\Source\Variables $configVariables - * @param \Magento\Widget\Model\ResourceModel\Widget $widgetResource - * @param \Magento\Widget\Model\Widget $widget + * @param \Magento\Variable\Model\VariableFactory $coreVariableFactory + * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\View\LayoutInterface $layout + * @param \Magento\Framework\View\LayoutFactory $layoutFactory + * @param \Magento\Framework\App\State $appState + * @param \Magento\Framework\UrlInterface $urlModel + * @param \Pelago\Emogrifier $emogrifier + * @param \Magento\Variable\Model\Source\Variables $configVariables + * @param \Magento\Widget\Model\ResourceModel\Widget $widgetResource + * @param \Magento\Widget\Model\Widget $widget + * @param array $directiveProcessors * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -54,7 +55,8 @@ public function __construct( \Pelago\Emogrifier $emogrifier, \Magento\Variable\Model\Source\Variables $configVariables, \Magento\Widget\Model\ResourceModel\Widget $widgetResource, - \Magento\Widget\Model\Widget $widget + \Magento\Widget\Model\Widget $widget, + array $directiveProcessors = [] ) { $this->_widgetResource = $widgetResource; $this->_widget = $widget; @@ -71,7 +73,10 @@ public function __construct( $appState, $urlModel, $emogrifier, - $configVariables + $configVariables, + [], + null, + $directiveProcessors ); } @@ -140,6 +145,7 @@ public function widgetDirective($construction) */ public function mediaDirective($construction) { + // phpcs:ignore Magento2.Functions.DiscouragedFunction $params = $this->getParameters(html_entity_decode($construction[2], ENT_QUOTES)); return $this->_storeManager->getStore() ->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . $params['url']; diff --git a/dev/tests/integration/testsuite/Magento/Widget/Model/Template/FilterTest.php b/dev/tests/integration/testsuite/Magento/Widget/Model/Template/FilterTest.php index fc3b0399d0497..d694db6b90cf6 100644 --- a/dev/tests/integration/testsuite/Magento/Widget/Model/Template/FilterTest.php +++ b/dev/tests/integration/testsuite/Magento/Widget/Model/Template/FilterTest.php @@ -34,4 +34,18 @@ public function testMediaDirectiveWithEncodedQuotes() $result = $filter->mediaDirective($construction); $this->assertEquals($baseUrl . $image, $result); } + + public function testCustomDirective() + { + // via TestModuleSimpleTemplateDirective + $template = '{{mydir "somevalue" param1=yes}}'; + $expected = 'SEYEULAVEMOS'; + + /** @var \Magento\Widget\Model\Template\Filter $filter */ + $filter = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Widget\Model\Template\Filter::class + ); + $result = $filter->filter($template); + $this->assertEquals($expected, $result); + } }