@@ -173,7 +173,7 @@ class Image extends \Magento\Framework\Model\AbstractModel
173
173
/**
174
174
* @var \Magento\Catalog\Model\View\Asset\ImageFactory
175
175
*/
176
- private $ viewAssetImageFactory ;
176
+ protected $ _viewAssetImageFactory ;
177
177
178
178
/**
179
179
* @var \Magento\Catalog\Model\View\Asset\PlaceholderFactory
@@ -198,6 +198,7 @@ class Image extends \Magento\Framework\Model\AbstractModel
198
198
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
199
199
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
200
200
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
201
+ * @param \Magento\Catalog\Model\View\Asset\ImageFactory $viewAssetImageFactory
201
202
* @param array $data
202
203
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
203
204
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
@@ -215,6 +216,7 @@ public function __construct(
215
216
\Magento \Framework \App \Config \ScopeConfigInterface $ scopeConfig ,
216
217
\Magento \Framework \Model \ResourceModel \AbstractResource $ resource = null ,
217
218
\Magento \Framework \Data \Collection \AbstractDb $ resourceCollection = null ,
219
+ \Magento \Catalog \Model \View \Asset \ImageFactory $ viewAssetImageFactory = null ,
218
220
array $ data = []
219
221
) {
220
222
$ this ->_storeManager = $ storeManager ;
@@ -226,6 +228,13 @@ public function __construct(
226
228
$ this ->_assetRepo = $ assetRepo ;
227
229
$ this ->_viewFileSystem = $ viewFileSystem ;
228
230
$ this ->_scopeConfig = $ scopeConfig ;
231
+ if ($ viewAssetImageFactory == null ) {
232
+ $ this ->_viewAssetImageFactory = ObjectManager::getInstance ()->get (
233
+ \Magento \Catalog \Model \View \Asset \ImageFactory::class
234
+ );
235
+ } else {
236
+ $ this ->_viewAssetImageFactory = $ viewAssetImageFactory ;
237
+ }
229
238
}
230
239
231
240
/**
@@ -469,7 +478,7 @@ public function setBaseFile($file)
469
478
{
470
479
$ this ->_isBaseFilePlaceholder = false ;
471
480
472
- $ this ->imageAsset = $ this ->getViewAssetImageFactory () ->create (
481
+ $ this ->imageAsset = $ this ->_viewAssetImageFactory ->create (
473
482
[
474
483
'miscParams ' => $ this ->getMiscParams (),
475
484
'filePath ' => $ file ,
@@ -894,20 +903,6 @@ public function getResizedImageInfo()
894
903
return getimagesize ($ image );
895
904
}
896
905
897
- /**
898
- * @return \Magento\Catalog\Model\View\Asset\ImageFactory
899
- */
900
- private function getViewAssetImageFactory ()
901
- {
902
- if ($ this ->viewAssetImageFactory == null ) {
903
- $ this ->viewAssetImageFactory = ObjectManager::getInstance ()->get (
904
- \Magento \Catalog \Model \View \Asset \ImageFactory::class
905
- );
906
- }
907
-
908
- return $ this ->viewAssetImageFactory ;
909
- }
910
-
911
906
/**
912
907
* @return \Magento\Catalog\Model\View\Asset\PlaceholderFactory
913
908
*/
0 commit comments