@@ -165,15 +165,20 @@ class Filter extends \Magento\Framework\Filter\Template
165165 protected $ configVariables ;
166166
167167 /**
168- * @var \Magento\Email\Model\Template\ Css\Processor
168+ * @var Css\Processor
169169 */
170170 private $ cssProcessor ;
171171
172172 /**
173- * @var ReadInterface
173+ * @var Filesystem
174174 */
175175 private $ pubDirectory ;
176176
177+ /**
178+ * @var \Magento\Framework\Filesystem\Directory\Read
179+ */
180+ private $ pubDirectoryRead ;
181+
177182 /**
178183 * @param \Magento\Framework\Stdlib\StringUtils $string
179184 * @param \Psr\Log\LoggerInterface $logger
@@ -190,7 +195,8 @@ class Filter extends \Magento\Framework\Filter\Template
190195 * @param \Magento\Variable\Model\Source\Variables $configVariables
191196 * @param array $variables
192197 * @param \Magento\Framework\Css\PreProcessor\Adapter\CssInliner|null $cssInliner
193- *
198+ * @param Css\Processor|null $cssProcessor
199+ * @param Filesystem|null $pubDirectory
194200 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
195201 */
196202 public function __construct (
@@ -208,7 +214,9 @@ public function __construct(
208214 \Pelago \Emogrifier $ emogrifier ,
209215 \Magento \Variable \Model \Source \Variables $ configVariables ,
210216 $ 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
212220 ) {
213221 $ this ->_escaper = $ escaper ;
214222 $ this ->_assetRepo = $ assetRepo ;
@@ -224,6 +232,10 @@ public function __construct(
224232 $ this ->emogrifier = $ emogrifier ;
225233 $ this ->cssInliner = $ cssInliner ?: \Magento \Framework \App \ObjectManager::getInstance ()
226234 ->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);
227239 $ this ->configVariables = $ configVariables ;
228240 parent ::__construct ($ string , $ variables );
229241 }
@@ -321,32 +333,14 @@ public function setDesignParams(array $designParams)
321333 }
322334
323335 /**
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
339337 *
340- * @deprecated 100.1.2
341338 * @param string $dirType
342- * @return ReadInterface
339+ * @return void
343340 */
344- private function getPubDirectory ($ dirType )
341+ private function setPubDirectory ($ dirType )
345342 {
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 );
350344 }
351345
352346 /**
@@ -844,7 +838,7 @@ public function cssDirective($construction)
844838 return '/* ' . __ ('"file" parameter must be specified ' ) . ' */ ' ;
845839 }
846840
847- $ css = $ this ->getCssProcessor () ->process (
841+ $ css = $ this ->cssProcessor ->process (
848842 $ this ->getCssFilesContent ([$ params ['file ' ]])
849843 );
850844
@@ -947,9 +941,9 @@ public function getCssFilesContent(array $files)
947941 try {
948942 foreach ($ files as $ file ) {
949943 $ 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 ());
953947 } else {
954948 $ css .= $ asset ->getContent ();
955949 }
@@ -979,7 +973,7 @@ public function applyInlineCss($html)
979973 $ cssToInline = $ this ->getCssFilesContent (
980974 $ this ->getInlineCssFiles ()
981975 );
982- $ cssToInline = $ this ->getCssProcessor () ->process ($ cssToInline );
976+ $ cssToInline = $ this ->cssProcessor ->process ($ cssToInline );
983977
984978 // Only run Emogrify if HTML and CSS contain content
985979 if ($ html && $ cssToInline ) {
0 commit comments