File tree Expand file tree Collapse file tree 6 files changed +20
-37
lines changed
app/code/Magento/Downloadable/Helper
dev/tests/unit/testsuite/Magento/Framework/Filesystem/File
lib/internal/Magento/Framework Expand file tree Collapse file tree 6 files changed +20
-37
lines changed Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ protected function _getHandle()
168
168
// Strip down protocol from path
169
169
$ path = preg_replace ('#.+://# ' , '' , $ path );
170
170
}
171
- $ this ->_handle = $ this ->fileReadFactory ->createWithDriverCode ($ path , $ protocol );
171
+ $ this ->_handle = $ this ->fileReadFactory ->create ($ path , $ protocol );
172
172
} elseif ($ this ->_linkType == self ::LINK_TYPE_FILE ) {
173
173
$ this ->_workingDirectory = $ this ->_filesystem ->getDirectoryRead (DirectoryList::MEDIA );
174
174
$ fileExists = $ this ->_downloadableFile ->ensureFileInFilesystem ($ this ->_resourceFile );
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ public function testCreateWithDriverCode()
30
30
$ driverMock ->expects ($ this ->any ())->method ('isExists ' )->willReturn (true );
31
31
$ driverPool ->expects ($ this ->once ())->method ('getDriver ' )->willReturn ($ driverMock );
32
32
$ factory = new ReadFactory ($ driverPool );
33
- $ result = $ factory ->createWithDriverCode ('path ' , 'driverCode ' );
33
+ $ result = $ factory ->create ('path ' , 'driverCode ' );
34
34
$ this ->assertInstanceOf ('Magento\Framework\Filesystem\File\Read ' , $ result );
35
35
}
36
36
}
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ public function testCreateWithDriverCode()
28
28
$ driverMock ->expects ($ this ->any ())->method ('isExists ' )->willReturn (true );
29
29
$ driverPool ->expects ($ this ->once ())->method ('getDriver ' )->willReturn ($ driverMock );
30
30
$ factory = new WriteFactory ($ driverPool );
31
- $ result = $ factory ->createWithDriverCode ('path ' , 'driverCode ' );
31
+ $ result = $ factory ->create ('path ' , 'driverCode ' );
32
32
$ this ->assertInstanceOf ('Magento\Framework\Filesystem\File\Write ' , $ result );
33
33
}
34
34
Original file line number Diff line number Diff line change @@ -52,21 +52,23 @@ public function __construct(
52
52
}
53
53
54
54
/**
55
- * Create an instance of directory with write permissions
55
+ * Create an instance of directory with read permissions
56
56
*
57
- * @param string $code
57
+ * @param string $directoryCode
58
+ * @param string $driverCode
58
59
* @return \Magento\Framework\Filesystem\Directory\ReadInterface
59
60
*/
60
- public function getDirectoryRead ($ code )
61
+ public function getDirectoryRead ($ directoryCode , $ driverCode = DriverPool:: FILE )
61
62
{
63
+ $ code = $ directoryCode . '_ ' . $ driverCode ;
62
64
if (!array_key_exists ($ code , $ this ->readInstances )) {
63
- $ this ->readInstances [$ code ] = $ this ->readFactory ->create ($ this ->getDirPath ($ code ) );
65
+ $ this ->readInstances [$ code ] = $ this ->readFactory ->create ($ this ->getDirPath ($ directoryCode ), $ driverCode );
64
66
}
65
67
return $ this ->readInstances [$ code ];
66
68
}
67
69
68
70
/**
69
- * Create an instance of directory with read permissions
71
+ * Create an instance of directory with write permissions
70
72
*
71
73
* @param string $directoryCode
72
74
* @param string $driverCode
Original file line number Diff line number Diff line change @@ -31,23 +31,14 @@ public function __construct(DriverPool $driverPool)
31
31
* Create a readable file
32
32
*
33
33
* @param string $path
34
- * @param DriverInterface $driver
34
+ * @param DriverInterface|string $driver Driver or driver code
35
35
* @return \Magento\Framework\Filesystem\File\ReadInterface
36
36
*/
37
- public function create ($ path , DriverInterface $ driver = null )
37
+ public function create ($ path , $ driver )
38
38
{
39
+ if (is_string ($ driver )) {
40
+ return new Read ($ path , $ this ->driverPool ->getDriver ($ driver ));
41
+ }
39
42
return new Read ($ path , $ driver );
40
43
}
41
-
42
- /**
43
- * Create a readable file
44
- *
45
- * @param string $path
46
- * @param string|null $driverCode
47
- * @return \Magento\Framework\Filesystem\File\ReadInterface
48
- */
49
- public function createWithDriverCode ($ path , $ driverCode )
50
- {
51
- return new Read ($ path , $ this ->driverPool ->getDriver ($ driverCode ));
52
- }
53
44
}
Original file line number Diff line number Diff line change @@ -31,25 +31,15 @@ public function __construct(DriverPool $driverPool)
31
31
* Create a readable file.
32
32
*
33
33
* @param string $path
34
- * @param DriverInterface $driver
34
+ * @param DriverInterface|string $driver Driver or driver code
35
35
* @param string $mode [optional]
36
36
* @return Write
37
37
*/
38
- public function create ($ path , DriverInterface $ driver , $ mode = 'r ' )
38
+ public function create ($ path , $ driver , $ mode = 'r ' )
39
39
{
40
+ if (is_string ($ driver )) {
41
+ return new Write ($ path , $ this ->driverPool ->getDriver ($ driver ), $ mode );
42
+ }
40
43
return new Write ($ path , $ driver , $ mode );
41
44
}
42
-
43
- /**
44
- * Create a readable file.
45
- *
46
- * @param string $path
47
- * @param string $driverCode
48
- * @param string $mode [optional]
49
- * @return Write
50
- */
51
- public function createWithDriverCode ($ path , $ driverCode , $ mode = 'r ' )
52
- {
53
- return new Write ($ path , $ this ->driverPool ->getDriver ($ driverCode ), $ mode );
54
- }
55
45
}
You can’t perform that action at this time.
0 commit comments