6
6
namespace Magento \Catalog \Model \Product ;
7
7
8
8
use Magento \Catalog \Model \Product \Image \NotLoadInfoImageException ;
9
+ use Magento \Catalog \Model \Product \Image \ParamsBuilder ;
9
10
use Magento \Catalog \Model \View \Asset \ImageFactory ;
10
11
use Magento \Catalog \Model \View \Asset \PlaceholderFactory ;
11
12
use Magento \Framework \App \Filesystem \DirectoryList ;
12
13
use Magento \Framework \App \ObjectManager ;
13
- use Magento \Framework \Exception \FileSystemException ;
14
14
use Magento \Framework \Image as MagentoImage ;
15
15
use Magento \Framework \Serialize \SerializerInterface ;
16
- use Magento \Catalog \Model \Product \Image \ParamsBuilder ;
17
- use Magento \Framework \Filesystem \Driver \File as FilesystemDriver ;
18
16
19
17
/**
20
18
* Image operations
@@ -202,11 +200,6 @@ class Image extends \Magento\Framework\Model\AbstractModel
202
200
*/
203
201
private $ serializer ;
204
202
205
- /**
206
- * @var FilesystemDriver
207
- */
208
- private $ filesystemDriver ;
209
-
210
203
/**
211
204
* Constructor
212
205
*
@@ -227,7 +220,6 @@ class Image extends \Magento\Framework\Model\AbstractModel
227
220
* @param array $data
228
221
* @param SerializerInterface $serializer
229
222
* @param ParamsBuilder $paramsBuilder
230
- * @param FilesystemDriver $filesystemDriver
231
223
* @throws \Magento\Framework\Exception\FileSystemException
232
224
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
233
225
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
@@ -249,8 +241,7 @@ public function __construct(
249
241
\Magento \Framework \Data \Collection \AbstractDb $ resourceCollection = null ,
250
242
array $ data = [],
251
243
SerializerInterface $ serializer = null ,
252
- ParamsBuilder $ paramsBuilder = null ,
253
- FilesystemDriver $ filesystemDriver = null
244
+ ParamsBuilder $ paramsBuilder = null
254
245
) {
255
246
$ this ->_storeManager = $ storeManager ;
256
247
$ this ->_catalogProductMediaConfig = $ catalogProductMediaConfig ;
@@ -265,7 +256,6 @@ public function __construct(
265
256
$ this ->viewAssetPlaceholderFactory = $ viewAssetPlaceholderFactory ;
266
257
$ this ->serializer = $ serializer ?: ObjectManager::getInstance ()->get (SerializerInterface::class);
267
258
$ this ->paramsBuilder = $ paramsBuilder ?: ObjectManager::getInstance ()->get (ParamsBuilder::class);
268
- $ this ->filesystemDriver = $ filesystemDriver ?: ObjectManager::getInstance ()->get (FilesystemDriver::class);
269
259
}
270
260
271
261
/**
@@ -675,12 +665,7 @@ public function getDestinationSubdir()
675
665
public function isCached ()
676
666
{
677
667
$ path = $ this ->imageAsset ->getPath ();
678
- try {
679
- $ isCached = is_array ($ this ->loadImageInfoFromCache ($ path )) || $ this ->filesystemDriver ->isExists ($ path );
680
- } catch (FileSystemException $ e ) {
681
- $ isCached = false ;
682
- }
683
- return $ isCached ;
668
+ return is_array ($ this ->loadImageInfoFromCache ($ path )) || $ this ->_mediaDirectory ->isExist ($ path );
684
669
}
685
670
686
671
/**
@@ -952,7 +937,7 @@ private function getImageSize($imagePath)
952
937
*/
953
938
private function saveImageInfoToCache (array $ imageInfo , string $ imagePath )
954
939
{
955
- $ imagePath = $ this ->cachePrefix . $ imagePath ;
940
+ $ imagePath = $ this ->cachePrefix . $ imagePath ;
956
941
$ this ->_cacheManager ->save (
957
942
$ this ->serializer ->serialize ($ imageInfo ),
958
943
$ imagePath ,
@@ -968,7 +953,7 @@ private function saveImageInfoToCache(array $imageInfo, string $imagePath)
968
953
*/
969
954
private function loadImageInfoFromCache (string $ imagePath )
970
955
{
971
- $ imagePath = $ this ->cachePrefix . $ imagePath ;
956
+ $ imagePath = $ this ->cachePrefix . $ imagePath ;
972
957
$ cacheData = $ this ->_cacheManager ->load ($ imagePath );
973
958
if (!$ cacheData ) {
974
959
return false ;
0 commit comments