Skip to content

Commit 627019b

Browse files
committed
MAGETWO-64085: Static versioning and styles minification break email fonts styles #8241
- fix code
1 parent ff986bd commit 627019b

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,16 @@ class Filter extends \Magento\Framework\Filter\Template
148148
*/
149149
protected $urlModel;
150150

151+
/**
152+
* @var \Pelago\Emogrifier
153+
* @deprecated
154+
*/
155+
protected $emogrifier;
156+
151157
/**
152158
* @var \Magento\Framework\Css\PreProcessor\Adapter\CssInliner
153159
*/
154-
protected $cssInliner;
160+
private $cssInliner;
155161

156162
/**
157163
* @var \Magento\Email\Model\Source\Variables
@@ -180,9 +186,10 @@ class Filter extends \Magento\Framework\Filter\Template
180186
* @param \Magento\Framework\View\LayoutFactory $layoutFactory
181187
* @param \Magento\Framework\App\State $appState
182188
* @param \Magento\Framework\UrlInterface $urlModel
183-
* @param \Magento\Framework\Css\PreProcessor\Adapter\CssInliner $cssInliner
189+
* @param \Pelago\Emogrifier $emogrifier
184190
* @param \Magento\Email\Model\Source\Variables $configVariables
185191
* @param array $variables
192+
* @param \Magento\Framework\Css\PreProcessor\Adapter\CssInliner|null $cssInliner
186193
*
187194
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
188195
*/
@@ -198,9 +205,10 @@ public function __construct(
198205
\Magento\Framework\View\LayoutFactory $layoutFactory,
199206
\Magento\Framework\App\State $appState,
200207
\Magento\Framework\UrlInterface $urlModel,
201-
\Magento\Framework\Css\PreProcessor\Adapter\CssInliner $cssInliner,
208+
\Pelago\Emogrifier $emogrifier,
202209
\Magento\Email\Model\Source\Variables $configVariables,
203-
$variables = []
210+
$variables = [],
211+
\Magento\Framework\Css\PreProcessor\Adapter\CssInliner $cssInliner = null
204212
) {
205213
$this->_escaper = $escaper;
206214
$this->_assetRepo = $assetRepo;
@@ -213,7 +221,9 @@ public function __construct(
213221
$this->_layoutFactory = $layoutFactory;
214222
$this->_appState = $appState;
215223
$this->urlModel = $urlModel;
216-
$this->cssInliner = $cssInliner;
224+
$this->emogrifier = $emogrifier;
225+
$this->cssInliner = $cssInliner ?: \Magento\Framework\App\ObjectManager::getInstance()
226+
->get(\Magento\Framework\Css\PreProcessor\Adapter\CssInliner::class);
217227
$this->configVariables = $configVariables;
218228
parent::__construct($string, $variables);
219229
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Filter extends \Magento\Cms\Model\Template\Filter
3333
* @param \Magento\Framework\View\LayoutFactory $layoutFactory
3434
* @param \Magento\Framework\App\State $appState
3535
* @param \Magento\Framework\UrlInterface $urlModel
36-
* @param \Magento\Framework\Css\PreProcessor\Adapter\CssInliner $cssInliner
36+
* @param \Pelago\Emogrifier $emogrifier
3737
* @param \Magento\Email\Model\Source\Variables $configVariables
3838
* @param \Magento\Widget\Model\ResourceModel\Widget $widgetResource
3939
* @param \Magento\Widget\Model\Widget $widget
@@ -51,7 +51,7 @@ public function __construct(
5151
\Magento\Framework\View\LayoutFactory $layoutFactory,
5252
\Magento\Framework\App\State $appState,
5353
\Magento\Framework\UrlInterface $urlModel,
54-
\Magento\Framework\Css\PreProcessor\Adapter\CssInliner $cssInliner,
54+
\Pelago\Emogrifier $emogrifier,
5555
\Magento\Email\Model\Source\Variables $configVariables,
5656
\Magento\Widget\Model\ResourceModel\Widget $widgetResource,
5757
\Magento\Widget\Model\Widget $widget
@@ -70,7 +70,7 @@ public function __construct(
7070
$layoutFactory,
7171
$appState,
7272
$urlModel,
73-
$cssInliner,
73+
$emogrifier,
7474
$configVariables
7575
);
7676
}

lib/internal/Magento/Framework/Css/PreProcessor/Adapter/CssInliner.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ class CssInliner
1919

2020
public function __construct()
2121
{
22-
$this->emogrifier = new Emogrifier;
22+
$this->emogrifier = new Emogrifier();
2323
}
2424

2525
/**
26-
* Sets the HTML to emogrify.
27-
*
28-
* @param string $html the HTML to emogrify, must be UTF-8-encoded
26+
* Sets the HTML to be used with the css.
27+
* This method should be used with setCss.
2928
*
29+
* @param string $html
3030
* @return void
3131
*/
3232
public function setHtml($html)
@@ -35,10 +35,10 @@ public function setHtml($html)
3535
}
3636

3737
/**
38-
* Sets the CSS to merge with the HTML.
39-
*
40-
* @param string $css the CSS to merge, must be UTF-8-encoded
38+
* Sets the CSS to be merged with the HTML.
39+
* This method should be used with setHtml.
4140
*
41+
* @param string $css
4242
* @return void
4343
*/
4444
public function setCss($css)
@@ -63,13 +63,10 @@ public function disableStyleBlocksParsing()
6363
}
6464

6565
/**
66-
* Applies $this->css to $this->html and returns the HTML with the CSS
67-
* applied.
68-
*
69-
* This method places the CSS inline.
66+
* Processes the html by placing the css inline.
67+
* You must set first the css by using setCss and html by using setHtml.
7068
*
7169
* @return string
72-
*
7370
* @throws \BadMethodCallException
7471
*/
7572
public function process()

0 commit comments

Comments
 (0)