@@ -165,15 +165,20 @@ class Filter extends \Magento\Framework\Filter\Template
165
165
protected $ configVariables ;
166
166
167
167
/**
168
- * @var \Magento\Email\Model\Template\ Css\Processor
168
+ * @var Css\Processor
169
169
*/
170
170
private $ cssProcessor ;
171
171
172
172
/**
173
- * @var ReadInterface
173
+ * @var Filesystem
174
174
*/
175
175
private $ pubDirectory ;
176
176
177
+ /**
178
+ * @var \Magento\Framework\Filesystem\Directory\Read
179
+ */
180
+ private $ pubDirectoryRead ;
181
+
177
182
/**
178
183
* @param \Magento\Framework\Stdlib\StringUtils $string
179
184
* @param \Psr\Log\LoggerInterface $logger
@@ -190,7 +195,8 @@ class Filter extends \Magento\Framework\Filter\Template
190
195
* @param \Magento\Variable\Model\Source\Variables $configVariables
191
196
* @param array $variables
192
197
* @param \Magento\Framework\Css\PreProcessor\Adapter\CssInliner|null $cssInliner
193
- *
198
+ * @param Css\Processor|null $cssProcessor
199
+ * @param Filesystem|null $pubDirectory
194
200
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
195
201
*/
196
202
public function __construct (
@@ -208,7 +214,9 @@ public function __construct(
208
214
\Pelago \Emogrifier $ emogrifier ,
209
215
\Magento \Variable \Model \Source \Variables $ configVariables ,
210
216
$ variables = [],
211
- \Magento \Framework \Css \PreProcessor \Adapter \CssInliner $ cssInliner = null
217
+ \Magento \Framework \Css \PreProcessor \Adapter \CssInliner $ cssInliner = null ,
218
+ Css \Processor $ cssProcessor = null ,
219
+ Filesystem $ pubDirectory = null
212
220
) {
213
221
$ this ->_escaper = $ escaper ;
214
222
$ this ->_assetRepo = $ assetRepo ;
@@ -224,6 +232,10 @@ public function __construct(
224
232
$ this ->emogrifier = $ emogrifier ;
225
233
$ this ->cssInliner = $ cssInliner ?: \Magento \Framework \App \ObjectManager::getInstance ()
226
234
->get (\Magento \Framework \Css \PreProcessor \Adapter \CssInliner::class);
235
+ $ this ->cssProcessor = $ cssProcessor ?: ObjectManager::getInstance ()
236
+ ->get (Css \Processor::class);
237
+ $ this ->pubDirectory = $ pubDirectory ?: ObjectManager::getInstance ()
238
+ ->get (Filesystem::class);
227
239
$ this ->configVariables = $ configVariables ;
228
240
parent ::__construct ($ string , $ variables );
229
241
}
@@ -321,32 +333,14 @@ public function setDesignParams(array $designParams)
321
333
}
322
334
323
335
/**
324
- * Get CSS processor
325
- *
326
- * @deprecated 100.1.2
327
- * @return Css\Processor
328
- */
329
- private function getCssProcessor ()
330
- {
331
- if (!$ this ->cssProcessor ) {
332
- $ this ->cssProcessor = ObjectManager::getInstance ()->get (Css \Processor::class);
333
- }
334
- return $ this ->cssProcessor ;
335
- }
336
-
337
- /**
338
- * Get pub directory
336
+ * Sets pub directory
339
337
*
340
- * @deprecated 100.1.2
341
338
* @param string $dirType
342
- * @return ReadInterface
339
+ * @return void
343
340
*/
344
- private function getPubDirectory ($ dirType )
341
+ private function setPubDirectory ($ dirType )
345
342
{
346
- if (!$ this ->pubDirectory ) {
347
- $ this ->pubDirectory = ObjectManager::getInstance ()->get (Filesystem::class)->getDirectoryRead ($ dirType );
348
- }
349
- return $ this ->pubDirectory ;
343
+ $ this ->pubDirectoryRead = $ this ->pubDirectory ->getDirectoryRead ($ dirType );
350
344
}
351
345
352
346
/**
@@ -844,7 +838,7 @@ public function cssDirective($construction)
844
838
return '/* ' . __ ('"file" parameter must be specified ' ) . ' */ ' ;
845
839
}
846
840
847
- $ css = $ this ->getCssProcessor () ->process (
841
+ $ css = $ this ->cssProcessor ->process (
848
842
$ this ->getCssFilesContent ([$ params ['file ' ]])
849
843
);
850
844
@@ -947,9 +941,9 @@ public function getCssFilesContent(array $files)
947
941
try {
948
942
foreach ($ files as $ file ) {
949
943
$ asset = $ this ->_assetRepo ->createAsset ($ file , $ designParams );
950
- $ pubDirectory = $ this ->getPubDirectory ($ asset ->getContext ()->getBaseDirType ());
951
- if ($ pubDirectory ->isExist ($ asset ->getPath ())) {
952
- $ css .= $ pubDirectory ->readFile ($ asset ->getPath ());
944
+ $ this ->setPubDirectory ($ asset ->getContext ()->getBaseDirType ());
945
+ if ($ this -> pubDirectoryRead ->isExist ($ asset ->getPath ())) {
946
+ $ css .= $ this -> pubDirectoryRead ->readFile ($ asset ->getPath ());
953
947
} else {
954
948
$ css .= $ asset ->getContent ();
955
949
}
@@ -979,7 +973,7 @@ public function applyInlineCss($html)
979
973
$ cssToInline = $ this ->getCssFilesContent (
980
974
$ this ->getInlineCssFiles ()
981
975
);
982
- $ cssToInline = $ this ->getCssProcessor () ->process ($ cssToInline );
976
+ $ cssToInline = $ this ->cssProcessor ->process ($ cssToInline );
983
977
984
978
// Only run Emogrify if HTML and CSS contain content
985
979
if ($ html && $ cssToInline ) {
0 commit comments