@@ -62,38 +62,41 @@ public function __construct(
62
62
* @param callable $proceed
63
63
* @return string
64
64
* @throws FileSystemException
65
+ * @throws \Magento\Framework\Exception\RuntimeException
65
66
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
66
67
*/
67
68
public function aroundGetImageWidth (Gallery $ subject , callable $ proceed ): string
68
69
{
69
- if ($ this ->config ->IsEnabled ()){
70
- $ file = $ subject ->getCurrentImage ()->getPath ();
71
- return $ this ->copyFileToTmp ($ file );
72
- }
70
+ return $ this ->copyFileToTmp ($ subject ,$ proceed );
73
71
}
74
72
75
73
/**
76
74
* Move files from storage to tmp folder
77
75
*
78
- * @param string $filePath
76
+ * @param Gallery $subject
77
+ * @param callable $proceed
79
78
* @return string
80
79
* @throws FileSystemException
80
+ * @throws \Magento\Framework\Exception\RuntimeException
81
81
*/
82
- private function copyFileToTmp (string $ filePath ): string
82
+ private function copyFileToTmp (Gallery $ subject , callable $ proceed ): string
83
83
{
84
- if ($ this ->fileExistsInTmp ($ filePath )) {
85
- return $ this ->tmpFiles [$ filePath ];
86
- }
87
- $ absolutePath = $ this ->remoteDirectoryWrite ->getAbsolutePath ($ filePath );
88
- if ($ this ->remoteDirectoryWrite ->isFile ($ absolutePath )) {
89
- $ this ->tmpDirectoryWrite ->create ();
90
- $ tmpPath = $ this ->storeTmpName ($ filePath );
91
- $ content = $ this ->remoteDirectoryWrite ->getDriver ()->fileGetContents ($ filePath );
92
- $ filePath = $ this ->tmpDirectoryWrite ->getDriver ()->filePutContents ($ tmpPath , $ content )
93
- ? $ tmpPath
94
- : $ filePath ;
84
+ if ($ this ->config ->IsEnabled ()) {
85
+ $ filePath = $ subject ->getCurrentImage ()->getPath ();
86
+ if ($ this ->fileExistsInTmp ($ filePath )) {
87
+ return $ this ->tmpFiles [$ filePath ];
88
+ }
89
+ $ absolutePath = $ this ->remoteDirectoryWrite ->getAbsolutePath ($ filePath );
90
+ if ($ this ->remoteDirectoryWrite ->isFile ($ absolutePath )) {
91
+ $ this ->tmpDirectoryWrite ->create ();
92
+ $ tmpPath = $ this ->storeTmpName ($ filePath );
93
+ $ content = $ this ->remoteDirectoryWrite ->getDriver ()->fileGetContents ($ filePath );
94
+ $ filePath = $ this ->tmpDirectoryWrite ->getDriver ()->filePutContents ($ tmpPath , $ content )
95
+ ? $ tmpPath
96
+ : $ filePath ;
97
+ }
98
+ return $ filePath ;
95
99
}
96
- return $ filePath ;
97
100
}
98
101
99
102
/**
0 commit comments