Skip to content

Commit 4523b3a

Browse files
authored
Merge pull request #31772 from konarshankar07/php8-miscellaneous-dependency
pelago/emogrifier and friendsofphp/php-cs-fixer updated
2 parents 0bd5384 + ce09f9f commit 4523b3a

File tree

8 files changed

+291
-218
lines changed

8 files changed

+291
-218
lines changed

app/code/Magento/Email/Model/Template/Filter.php

Lines changed: 145 additions & 129 deletions
Large diffs are not rendered by default.

app/code/Magento/Email/Test/Unit/Model/Template/FilterTest.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
use Magento\Store\Model\StoreManagerInterface;
3939
use Magento\Variable\Model\Source\Variables;
4040
use Magento\Variable\Model\VariableFactory;
41-
use Pelago\Emogrifier;
4241
use PHPUnit\Framework\MockObject\MockObject;
4342
use PHPUnit\Framework\TestCase;
4443
use Psr\Log\LoggerInterface;
@@ -114,11 +113,6 @@ class FilterTest extends TestCase
114113
*/
115114
private $configVariables;
116115

117-
/**
118-
* @var Emogrifier
119-
*/
120-
private $emogrifier;
121-
122116
/**
123117
* @var CssInliner
124118
*/
@@ -144,6 +138,11 @@ class FilterTest extends TestCase
144138
*/
145139
private $variableResolver;
146140

141+
/**
142+
* @var MockObject|VariableResolverInterface
143+
*/
144+
private $variableResolverInterface;
145+
147146
/**
148147
* @var array
149148
*/
@@ -195,8 +194,6 @@ protected function setUp(): void
195194
->disableOriginalConstructor()
196195
->getMockForAbstractClass();
197196

198-
$this->emogrifier = $this->objectManager->getObject(Emogrifier::class);
199-
200197
$this->configVariables = $this->getMockBuilder(Variables::class)
201198
->disableOriginalConstructor()
202199
->getMock();
@@ -257,14 +254,13 @@ protected function getModel($mockedMethods = null)
257254
$this->layoutFactory,
258255
$this->appState,
259256
$this->backendUrlBuilder,
260-
$this->emogrifier,
261257
$this->configVariables,
262-
[],
263-
$this->cssInliner,
264-
$this->directiveProcessors,
265258
$this->variableResolver,
266259
$this->cssProcessor,
267-
$this->pubDirectory
260+
$this->pubDirectory,
261+
$this->cssInliner,
262+
[],
263+
$this->directiveProcessors
268264
]
269265
)
270266
->setMethods($mockedMethods)

app/code/Magento/Widget/Model/Template/Filter.php

Lines changed: 69 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@
55
*/
66
namespace Magento\Widget\Model\Template;
77

8+
use Magento\Email\Model\Template\Css;
9+
use Magento\Framework\App\Config\ScopeConfigInterface;
10+
use Magento\Framework\App\State;
11+
use Magento\Framework\Css\PreProcessor\Adapter\CssInliner;
12+
use Magento\Framework\Escaper;
13+
use Magento\Framework\Filesystem;
14+
use Magento\Framework\Filter\VariableResolverInterface;
15+
use Magento\Framework\Stdlib\StringUtils;
16+
use Magento\Framework\UrlInterface;
17+
use Magento\Framework\View\Asset\Repository;
18+
use Magento\Framework\View\LayoutFactory;
19+
use Magento\Framework\View\LayoutInterface;
20+
use Magento\Store\Model\StoreManagerInterface;
21+
use Magento\Variable\Model\Source\Variables;
22+
use Magento\Variable\Model\VariableFactory;
23+
use Magento\Widget\Block\BlockInterface;
24+
use Magento\Widget\Model\Widget;
25+
use Psr\Log\LoggerInterface;
26+
827
/**
928
* Template Filter Model
1029
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -17,44 +36,55 @@ class Filter extends \Magento\Cms\Model\Template\Filter
1736
protected $_widgetResource;
1837

1938
/**
20-
* @var \Magento\Widget\Model\Widget
39+
* @var Widget
2140
*/
2241
protected $_widget;
2342

2443
/**
25-
* @param \Magento\Framework\Stdlib\StringUtils $string
26-
* @param \Psr\Log\LoggerInterface $logger
27-
* @param \Magento\Framework\Escaper $escaper
28-
* @param \Magento\Framework\View\Asset\Repository $assetRepo
29-
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
30-
* @param \Magento\Variable\Model\VariableFactory $coreVariableFactory
31-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
32-
* @param \Magento\Framework\View\LayoutInterface $layout
33-
* @param \Magento\Framework\View\LayoutFactory $layoutFactory
34-
* @param \Magento\Framework\App\State $appState
35-
* @param \Magento\Framework\UrlInterface $urlModel
36-
* @param \Pelago\Emogrifier $emogrifier
37-
* @param \Magento\Variable\Model\Source\Variables $configVariables
44+
* Filter constructor.
45+
* @param StringUtils $string
46+
* @param LoggerInterface $logger
47+
* @param Escaper $escaper
48+
* @param Repository $assetRepo
49+
* @param ScopeConfigInterface $scopeConfig
50+
* @param VariableFactory $coreVariableFactory
51+
* @param StoreManagerInterface $storeManager
52+
* @param LayoutInterface $layout
53+
* @param LayoutFactory $layoutFactory
54+
* @param State $appState
55+
* @param UrlInterface $urlModel
56+
* @param Variables $configVariables
57+
* @param VariableResolverInterface $variableResolver
58+
* @param Css\Processor $cssProcessor
59+
* @param Filesystem $pubDirectory
60+
* @param CssInliner $cssInliner
3861
* @param \Magento\Widget\Model\ResourceModel\Widget $widgetResource
39-
* @param \Magento\Widget\Model\Widget $widget
62+
* @param Widget $widget
63+
* @param array $variables
64+
* @param array $directiveProcessors
4065
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
4166
*/
4267
public function __construct(
43-
\Magento\Framework\Stdlib\StringUtils $string,
44-
\Psr\Log\LoggerInterface $logger,
45-
\Magento\Framework\Escaper $escaper,
46-
\Magento\Framework\View\Asset\Repository $assetRepo,
47-
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
48-
\Magento\Variable\Model\VariableFactory $coreVariableFactory,
49-
\Magento\Store\Model\StoreManagerInterface $storeManager,
50-
\Magento\Framework\View\LayoutInterface $layout,
51-
\Magento\Framework\View\LayoutFactory $layoutFactory,
52-
\Magento\Framework\App\State $appState,
53-
\Magento\Framework\UrlInterface $urlModel,
54-
\Pelago\Emogrifier $emogrifier,
55-
\Magento\Variable\Model\Source\Variables $configVariables,
68+
StringUtils $string,
69+
LoggerInterface $logger,
70+
Escaper $escaper,
71+
Repository $assetRepo,
72+
ScopeConfigInterface $scopeConfig,
73+
VariableFactory $coreVariableFactory,
74+
StoreManagerInterface $storeManager,
75+
LayoutInterface $layout,
76+
LayoutFactory $layoutFactory,
77+
State $appState,
78+
UrlInterface $urlModel,
79+
Variables $configVariables,
80+
VariableResolverInterface $variableResolver,
81+
Css\Processor $cssProcessor,
82+
Filesystem $pubDirectory,
83+
CssInliner $cssInliner,
5684
\Magento\Widget\Model\ResourceModel\Widget $widgetResource,
57-
\Magento\Widget\Model\Widget $widget
85+
Widget $widget,
86+
$variables = [],
87+
array $directiveProcessors = []
5888
) {
5989
$this->_widgetResource = $widgetResource;
6090
$this->_widget = $widget;
@@ -70,8 +100,13 @@ public function __construct(
70100
$layoutFactory,
71101
$appState,
72102
$urlModel,
73-
$emogrifier,
74-
$configVariables
103+
$configVariables,
104+
$variableResolver,
105+
$cssProcessor,
106+
$pubDirectory,
107+
$cssInliner,
108+
$variables,
109+
$directiveProcessors
75110
);
76111
}
77112

@@ -114,7 +149,7 @@ public function generateWidget($construction)
114149

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

@@ -140,8 +175,9 @@ public function widgetDirective($construction)
140175
*/
141176
public function mediaDirective($construction)
142177
{
178+
// phpcs:disable Magento2.Functions.DiscouragedFunction
143179
$params = $this->getParameters(html_entity_decode($construction[2], ENT_QUOTES));
144180
return $this->_storeManager->getStore()
145-
->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . $params['url'];
181+
->getBaseUrl(UrlInterface::URL_TYPE_MEDIA) . $params['url'];
146182
}
147183
}

app/code/Magento/Widget/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"magento/module-backend": "*",
1111
"magento/module-catalog": "*",
1212
"magento/module-cms": "*",
13+
"magento/module-email": "*",
1314
"magento/module-store": "*",
1415
"magento/module-theme": "*",
1516
"magento/module-variable": "*",

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"magento/zendframework1": "~1.14.2",
7070
"monolog/monolog": "^1.17",
7171
"paragonie/sodium_compat": "^1.6",
72-
"pelago/emogrifier": "^3.1.0",
72+
"pelago/emogrifier": "^5.0.0",
7373
"php-amqplib/php-amqplib": "~2.10.0",
7474
"phpseclib/mcrypt_compat": "1.0.8",
7575
"phpseclib/phpseclib": "2.0.*",
@@ -88,7 +88,7 @@
8888
"require-dev": {
8989
"allure-framework/allure-phpunit": "~1.2.0",
9090
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
91-
"friendsofphp/php-cs-fixer": "~2.16.0",
91+
"friendsofphp/php-cs-fixer": "~2.18.1",
9292
"lusitanian/oauth": "~0.8.10",
9393
"magento/magento-coding-standard": "*",
9494
"magento/magento2-functional-testing-framework": "^3.0",

composer.lock

Lines changed: 27 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)