Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pelago/emogrifier and friendsofphp/php-cs-fixer updated #31772

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
274 changes: 145 additions & 129 deletions app/code/Magento/Email/Model/Template/Filter.php

Large diffs are not rendered by default.

22 changes: 9 additions & 13 deletions app/code/Magento/Email/Test/Unit/Model/Template/FilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
use Magento\Store\Model\StoreManagerInterface;
use Magento\Variable\Model\Source\Variables;
use Magento\Variable\Model\VariableFactory;
use Pelago\Emogrifier;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -114,11 +113,6 @@ class FilterTest extends TestCase
*/
private $configVariables;

/**
* @var Emogrifier
*/
private $emogrifier;

/**
* @var CssInliner
*/
Expand All @@ -144,6 +138,11 @@ class FilterTest extends TestCase
*/
private $variableResolver;

/**
* @var MockObject|VariableResolverInterface
*/
private $variableResolverInterface;

/**
* @var array
*/
Expand Down Expand Up @@ -195,8 +194,6 @@ protected function setUp(): void
->disableOriginalConstructor()
->getMockForAbstractClass();

$this->emogrifier = $this->objectManager->getObject(Emogrifier::class);

$this->configVariables = $this->getMockBuilder(Variables::class)
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -257,14 +254,13 @@ protected function getModel($mockedMethods = null)
$this->layoutFactory,
$this->appState,
$this->backendUrlBuilder,
$this->emogrifier,
$this->configVariables,
[],
$this->cssInliner,
$this->directiveProcessors,
$this->variableResolver,
$this->cssProcessor,
$this->pubDirectory
$this->pubDirectory,
$this->cssInliner,
[],
$this->directiveProcessors
]
)
->setMethods($mockedMethods)
Expand Down
102 changes: 69 additions & 33 deletions app/code/Magento/Widget/Model/Template/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@
*/
namespace Magento\Widget\Model\Template;

use Magento\Email\Model\Template\Css;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\State;
use Magento\Framework\Css\PreProcessor\Adapter\CssInliner;
use Magento\Framework\Escaper;
use Magento\Framework\Filesystem;
use Magento\Framework\Filter\VariableResolverInterface;
use Magento\Framework\Stdlib\StringUtils;
use Magento\Framework\UrlInterface;
use Magento\Framework\View\Asset\Repository;
use Magento\Framework\View\LayoutFactory;
use Magento\Framework\View\LayoutInterface;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Variable\Model\Source\Variables;
use Magento\Variable\Model\VariableFactory;
use Magento\Widget\Block\BlockInterface;
use Magento\Widget\Model\Widget;
use Psr\Log\LoggerInterface;

/**
* Template Filter Model
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Expand All @@ -17,44 +36,55 @@ class Filter extends \Magento\Cms\Model\Template\Filter
protected $_widgetResource;

/**
* @var \Magento\Widget\Model\Widget
* @var Widget
*/
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\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
* Filter constructor.
* @param StringUtils $string
* @param LoggerInterface $logger
* @param Escaper $escaper
* @param Repository $assetRepo
* @param ScopeConfigInterface $scopeConfig
* @param VariableFactory $coreVariableFactory
* @param StoreManagerInterface $storeManager
* @param LayoutInterface $layout
* @param LayoutFactory $layoutFactory
* @param State $appState
* @param UrlInterface $urlModel
* @param Variables $configVariables
* @param VariableResolverInterface $variableResolver
* @param Css\Processor $cssProcessor
* @param Filesystem $pubDirectory
* @param CssInliner $cssInliner
* @param \Magento\Widget\Model\ResourceModel\Widget $widgetResource
* @param \Magento\Widget\Model\Widget $widget
* @param Widget $widget
* @param array $variables
* @param array $directiveProcessors
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
\Magento\Framework\Stdlib\StringUtils $string,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Escaper $escaper,
\Magento\Framework\View\Asset\Repository $assetRepo,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Variable\Model\VariableFactory $coreVariableFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\View\LayoutInterface $layout,
\Magento\Framework\View\LayoutFactory $layoutFactory,
\Magento\Framework\App\State $appState,
\Magento\Framework\UrlInterface $urlModel,
\Pelago\Emogrifier $emogrifier,
\Magento\Variable\Model\Source\Variables $configVariables,
StringUtils $string,
LoggerInterface $logger,
Escaper $escaper,
Repository $assetRepo,
ScopeConfigInterface $scopeConfig,
VariableFactory $coreVariableFactory,
StoreManagerInterface $storeManager,
LayoutInterface $layout,
LayoutFactory $layoutFactory,
State $appState,
UrlInterface $urlModel,
Variables $configVariables,
VariableResolverInterface $variableResolver,
Css\Processor $cssProcessor,
Filesystem $pubDirectory,
CssInliner $cssInliner,
\Magento\Widget\Model\ResourceModel\Widget $widgetResource,
\Magento\Widget\Model\Widget $widget
Widget $widget,
$variables = [],
array $directiveProcessors = []
) {
$this->_widgetResource = $widgetResource;
$this->_widget = $widget;
Expand All @@ -70,8 +100,13 @@ public function __construct(
$layoutFactory,
$appState,
$urlModel,
$emogrifier,
$configVariables
$configVariables,
$variableResolver,
$cssProcessor,
$pubDirectory,
$cssInliner,
$variables,
$directiveProcessors
);
}

Expand Down Expand Up @@ -114,7 +149,7 @@ public function generateWidget($construction)

// define widget block and check the type is instance of Widget Interface
$widget = $this->_layout->createBlock($type, $name, ['data' => $params]);
if (!$widget instanceof \Magento\Widget\Block\BlockInterface) {
if (!$widget instanceof BlockInterface) {
return '';
}

Expand All @@ -140,8 +175,9 @@ public function widgetDirective($construction)
*/
public function mediaDirective($construction)
{
// phpcs:disable 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'];
->getBaseUrl(UrlInterface::URL_TYPE_MEDIA) . $params['url'];
}
}
1 change: 1 addition & 0 deletions app/code/Magento/Widget/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"magento/module-backend": "*",
"magento/module-catalog": "*",
"magento/module-cms": "*",
"magento/module-email": "*",
"magento/module-store": "*",
"magento/module-theme": "*",
"magento/module-variable": "*",
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"magento/zendframework1": "~1.14.2",
"monolog/monolog": "^1.17",
"paragonie/sodium_compat": "^1.6",
"pelago/emogrifier": "^3.1.0",
"pelago/emogrifier": "^5.0.0",
"php-amqplib/php-amqplib": "~2.10.0",
"phpseclib/mcrypt_compat": "1.0.8",
"phpseclib/phpseclib": "2.0.*",
Expand All @@ -88,7 +88,7 @@
"require-dev": {
"allure-framework/allure-phpunit": "~1.2.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
"friendsofphp/php-cs-fixer": "~2.16.0",
"friendsofphp/php-cs-fixer": "~2.18.1",
"lusitanian/oauth": "~0.8.10",
"magento/magento-coding-standard": "*",
"magento/magento2-functional-testing-framework": "^3.0",
Expand Down
53 changes: 27 additions & 26 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading