66namespace Magento \Catalog \Model \Product ;
77
88use Magento \Catalog \Model \Product \Image \NotLoadInfoImageException ;
9+ use Magento \Catalog \Model \Product \Image \ParamsBuilder ;
910use Magento \Catalog \Model \View \Asset \ImageFactory ;
1011use Magento \Catalog \Model \View \Asset \PlaceholderFactory ;
1112use Magento \Framework \App \Filesystem \DirectoryList ;
1213use Magento \Framework \App \ObjectManager ;
13- use Magento \Framework \Exception \FileSystemException ;
1414use Magento \Framework \Image as MagentoImage ;
1515use Magento \Framework \Serialize \SerializerInterface ;
16- use Magento \Catalog \Model \Product \Image \ParamsBuilder ;
17- use Magento \Framework \Filesystem \Driver \File as FilesystemDriver ;
1816
1917/**
2018 * Image operations
@@ -202,11 +200,6 @@ class Image extends \Magento\Framework\Model\AbstractModel
202200 */
203201 private $ serializer ;
204202
205- /**
206- * @var FilesystemDriver
207- */
208- private $ filesystemDriver ;
209-
210203 /**
211204 * Constructor
212205 *
@@ -227,7 +220,6 @@ class Image extends \Magento\Framework\Model\AbstractModel
227220 * @param array $data
228221 * @param SerializerInterface $serializer
229222 * @param ParamsBuilder $paramsBuilder
230- * @param FilesystemDriver $filesystemDriver
231223 * @throws \Magento\Framework\Exception\FileSystemException
232224 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
233225 * @SuppressWarnings(PHPMD.UnusedLocalVariable)
@@ -249,8 +241,7 @@ public function __construct(
249241 \Magento \Framework \Data \Collection \AbstractDb $ resourceCollection = null ,
250242 array $ data = [],
251243 SerializerInterface $ serializer = null ,
252- ParamsBuilder $ paramsBuilder = null ,
253- FilesystemDriver $ filesystemDriver = null
244+ ParamsBuilder $ paramsBuilder = null
254245 ) {
255246 $ this ->_storeManager = $ storeManager ;
256247 $ this ->_catalogProductMediaConfig = $ catalogProductMediaConfig ;
@@ -265,7 +256,6 @@ public function __construct(
265256 $ this ->viewAssetPlaceholderFactory = $ viewAssetPlaceholderFactory ;
266257 $ this ->serializer = $ serializer ?: ObjectManager::getInstance ()->get (SerializerInterface::class);
267258 $ this ->paramsBuilder = $ paramsBuilder ?: ObjectManager::getInstance ()->get (ParamsBuilder::class);
268- $ this ->filesystemDriver = $ filesystemDriver ?: ObjectManager::getInstance ()->get (FilesystemDriver::class);
269259 }
270260
271261 /**
@@ -675,12 +665,7 @@ public function getDestinationSubdir()
675665 public function isCached ()
676666 {
677667 $ 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 );
684669 }
685670
686671 /**
@@ -952,7 +937,7 @@ private function getImageSize($imagePath)
952937 */
953938 private function saveImageInfoToCache (array $ imageInfo , string $ imagePath )
954939 {
955- $ imagePath = $ this ->cachePrefix . $ imagePath ;
940+ $ imagePath = $ this ->cachePrefix . $ imagePath ;
956941 $ this ->_cacheManager ->save (
957942 $ this ->serializer ->serialize ($ imageInfo ),
958943 $ imagePath ,
@@ -968,7 +953,7 @@ private function saveImageInfoToCache(array $imageInfo, string $imagePath)
968953 */
969954 private function loadImageInfoFromCache (string $ imagePath )
970955 {
971- $ imagePath = $ this ->cachePrefix . $ imagePath ;
956+ $ imagePath = $ this ->cachePrefix . $ imagePath ;
972957 $ cacheData = $ this ->_cacheManager ->load ($ imagePath );
973958 if (!$ cacheData ) {
974959 return false ;
0 commit comments