@@ -34,19 +34,27 @@ class Uploader extends \Magento\Framework\File\Uploader
34
34
/**
35
35
* Copies file to the tmp directory if remote storage is enabled and tmp file is located on remote storage
36
36
*
37
- * {@inheritDoc}
37
+ * @param string|array $fileId
38
+ * @param Mime|null $fileMime
39
+ * @param DirectoryList|null $directoryList
40
+ * @param DriverPool|null $driverPool
41
+ * @param TargetDirectory|null $targetDirectory
42
+ * @param Filesystem|null $filesystem
43
+ * @param Config|null $config
44
+ * @throws \DomainException
38
45
*/
39
46
public function __construct (
40
47
$ fileId ,
41
48
Mime $ fileMime = null ,
42
49
DirectoryList $ directoryList = null ,
43
50
DriverPool $ driverPool = null ,
44
51
TargetDirectory $ targetDirectory = null ,
45
- Filesystem $ filesystem = null
52
+ Filesystem $ filesystem = null ,
53
+ Config $ config = null
46
54
) {
47
55
$ targetDirectory = $ targetDirectory ?: ObjectManager::getInstance ()->get (TargetDirectory::class);
48
56
$ filesystem = $ filesystem ?: ObjectManager::getInstance ()->get (FileSystem::class);
49
- $ config = ObjectManager::getInstance ()->get (Config::class);
57
+ $ config = $ config ?: ObjectManager::getInstance ()->get (Config::class);
50
58
51
59
if ($ config ->isEnabled () && isset ($ fileId ['tmp_name ' ])) {
52
60
$ this ->tmpDirectoryWrite = $ filesystem ->getDirectoryWrite (DirectoryList::TMP );
@@ -70,6 +78,7 @@ private function copyFileToTmp(string $filePath): string
70
78
$ absolutePath = $ this ->remoteDirectoryWrite ->getAbsolutePath ($ filePath );
71
79
if ($ this ->remoteDirectoryWrite ->isFile ($ absolutePath )) {
72
80
$ this ->tmpDirectoryWrite ->create ();
81
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction
73
82
$ tmpPath = $ this ->tmpDirectoryWrite ->getAbsolutePath () . basename ($ filePath );
74
83
$ content = $ this ->remoteDirectoryWrite ->getDriver ()->fileGetContents ($ filePath );
75
84
$ this ->tmpDirectoryWrite ->getDriver ()->filePutContents ($ tmpPath , $ content );
0 commit comments