@@ -199,6 +199,8 @@ class Image extends \Magento\Framework\Model\AbstractModel
199
199
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
200
200
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
201
201
* @param array $data
202
+ * @param \Magento\Catalog\Model\View\Asset\ImageFactory $assetImageFactory
203
+ * @param \Magento\Catalog\Model\View\Asset\PlaceholderFactory $assetPlaceholderFactory
202
204
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
203
205
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
204
206
*/
@@ -215,7 +217,9 @@ public function __construct(
215
217
\Magento \Framework \App \Config \ScopeConfigInterface $ scopeConfig ,
216
218
\Magento \Framework \Model \ResourceModel \AbstractResource $ resource = null ,
217
219
\Magento \Framework \Data \Collection \AbstractDb $ resourceCollection = null ,
218
- array $ data = []
220
+ array $ data = [],
221
+ \Magento \Catalog \Model \View \Asset \ImageFactory $ assetImageFactory = null ,
222
+ \Magento \Catalog \Model \View \Asset \PlaceholderFactory $ assetPlaceholderFactory = null
219
223
) {
220
224
$ this ->_storeManager = $ storeManager ;
221
225
$ this ->_catalogProductMediaConfig = $ catalogProductMediaConfig ;
@@ -226,6 +230,18 @@ public function __construct(
226
230
$ this ->_assetRepo = $ assetRepo ;
227
231
$ this ->_viewFileSystem = $ viewFileSystem ;
228
232
$ this ->_scopeConfig = $ scopeConfig ;
233
+ $ this ->viewAssetImageFactory = $ assetImageFactory ;
234
+ if ($ this ->viewAssetImageFactory == null ) {
235
+ $ this ->viewAssetImageFactory = ObjectManager::getInstance ()->get (
236
+ \Magento \Catalog \Model \View \Asset \ImageFactory::class
237
+ );
238
+ }
239
+ $ this ->viewAssetPlaceholderFactory = $ assetPlaceholderFactory ;
240
+ if ($ this ->viewAssetPlaceholderFactory == null ) {
241
+ $ this ->viewAssetPlaceholderFactory = ObjectManager::getInstance ()->get (
242
+ \Magento \Catalog \Model \View \Asset \PlaceholderFactory::class
243
+ );
244
+ }
229
245
}
230
246
231
247
/**
@@ -469,7 +485,7 @@ public function setBaseFile($file)
469
485
{
470
486
$ this ->_isBaseFilePlaceholder = false ;
471
487
472
- $ this ->imageAsset = $ this ->getViewAssetImageFactory () ->create (
488
+ $ this ->imageAsset = $ this ->viewAssetImageFactory ->create (
473
489
[
474
490
'miscParams ' => $ this ->getMiscParams (),
475
491
'filePath ' => $ file ,
@@ -479,7 +495,7 @@ public function setBaseFile($file)
479
495
|| !$ this ->_checkMemory ($ this ->imageAsset ->getSourceFile ())
480
496
) {
481
497
$ this ->_isBaseFilePlaceholder = true ;
482
- $ this ->imageAsset = $ this ->getViewAssetPlaceholderFactory () ->create (
498
+ $ this ->imageAsset = $ this ->viewAssetPlaceholderFactory ->create (
483
499
[
484
500
'type ' => $ this ->getDestinationSubdir (),
485
501
]
@@ -895,38 +911,6 @@ public function getResizedImageInfo()
895
911
return getimagesize ($ image );
896
912
}
897
913
898
- /**
899
- * Get assets ImageFactory object
900
- *
901
- * @return \Magento\Catalog\Model\View\Asset\ImageFactory
902
- */
903
- private function getViewAssetImageFactory ()
904
- {
905
- if ($ this ->viewAssetImageFactory == null ) {
906
- $ this ->viewAssetImageFactory = ObjectManager::getInstance ()->get (
907
- \Magento \Catalog \Model \View \Asset \ImageFactory::class
908
- );
909
- }
910
-
911
- return $ this ->viewAssetImageFactory ;
912
- }
913
-
914
- /**
915
- * Get assets PlaceholderFactory object
916
- *
917
- * @return \Magento\Catalog\Model\View\Asset\PlaceholderFactory
918
- */
919
- private function getViewAssetPlaceholderFactory ()
920
- {
921
- if ($ this ->viewAssetPlaceholderFactory == null ) {
922
- $ this ->viewAssetPlaceholderFactory = ObjectManager::getInstance ()->get (
923
- \Magento \Catalog \Model \View \Asset \PlaceholderFactory::class
924
- );
925
- }
926
-
927
- return $ this ->viewAssetPlaceholderFactory ;
928
- }
929
-
930
914
/**
931
915
* Retrieve misc params based on all image attributes
932
916
*
0 commit comments