5
5
*/
6
6
namespace Magento \Framework \Filesystem \Directory ;
7
7
8
+ use FilesystemIterator ;
8
9
use Magento \Framework \Exception \FileSystemException ;
9
10
use Magento \Framework \Exception \ValidatorException ;
11
+ use Magento \Framework \Filesystem \DriverInterface ;
10
12
11
13
/**
14
+ * Directory Read Class
15
+ *
12
16
* @api
13
17
* @since 100.0.2
14
18
*/
@@ -31,11 +35,13 @@ class Read implements ReadInterface
31
35
/**
32
36
* Filesystem driver
33
37
*
34
- * @var \Magento\Framework\Filesystem\ DriverInterface
38
+ * @var DriverInterface
35
39
*/
36
40
protected $ driver ;
37
41
38
42
/**
43
+ * Validator for path strings
44
+ *
39
45
* @var PathValidatorInterface|null
40
46
*/
41
47
private $ pathValidator ;
@@ -44,13 +50,13 @@ class Read implements ReadInterface
44
50
* Constructor. Set properties.
45
51
*
46
52
* @param \Magento\Framework\Filesystem\File\ReadFactory $fileFactory
47
- * @param \Magento\Framework\Filesystem\ DriverInterface $driver
53
+ * @param DriverInterface $driver
48
54
* @param string $path
49
55
* @param PathValidatorInterface|null $pathValidator
50
56
*/
51
57
public function __construct (
52
58
\Magento \Framework \Filesystem \File \ReadFactory $ fileFactory ,
53
- \ Magento \ Framework \ Filesystem \ DriverInterface $ driver ,
59
+ DriverInterface $ driver ,
54
60
$ path ,
55
61
?PathValidatorInterface $ pathValidator = null
56
62
) {
@@ -61,6 +67,8 @@ public function __construct(
61
67
}
62
68
63
69
/**
70
+ * Validate provided path with scheme.
71
+ *
64
72
* @param null|string $path
65
73
* @param null|string $scheme
66
74
* @param bool $absolutePath
@@ -88,6 +96,7 @@ protected function validatePath(
88
96
* Sets base path
89
97
*
90
98
* @param string $path
99
+ *
91
100
* @return void
92
101
*/
93
102
protected function setPath ($ path )
@@ -98,12 +107,12 @@ protected function setPath($path)
98
107
}
99
108
100
109
/**
101
- * Retrieves absolute path
102
- * E.g.: /var/www/application/file.txt
110
+ * Retrieves absolute path E.g.: /var/www/application/file.txt
103
111
*
104
112
* @param string $path
105
113
* @param string $scheme
106
114
* @throws ValidatorException
115
+ *
107
116
* @return string
108
117
*/
109
118
public function getAbsolutePath ($ path = null , $ scheme = null )
@@ -135,6 +144,7 @@ public function getRelativePath($path = null)
135
144
* Retrieve list of all entities in given path
136
145
*
137
146
* @param string|null $path
147
+ * @throws FileSystemException
138
148
* @throws ValidatorException
139
149
* @return string[]
140
150
*/
@@ -153,7 +163,8 @@ public function read($path = null)
153
163
/**
154
164
* Read recursively
155
165
*
156
- * @param null $path
166
+ * @param string|null $path
167
+ * @throws FileSystemException
157
168
* @throws ValidatorException
158
169
* @return string[]
159
170
*/
@@ -163,7 +174,7 @@ public function readRecursively($path = null)
163
174
164
175
$ result = [];
165
176
$ paths = $ this ->driver ->readDirectoryRecursively ($ this ->driver ->getAbsolutePath ($ this ->path , $ path ));
166
- /** @var \ FilesystemIterator $file */
177
+ /** @var FilesystemIterator $file */
167
178
foreach ($ paths as $ file ) {
168
179
$ result [] = $ this ->getRelativePath ($ file );
169
180
}
@@ -176,6 +187,7 @@ public function readRecursively($path = null)
176
187
*
177
188
* @param string $pattern
178
189
* @param string $path [optional]
190
+ * @throws FileSystemException
179
191
* @throws ValidatorException
180
192
* @return string[]
181
193
*/
@@ -202,24 +214,22 @@ public function search($pattern, $path = null)
202
214
*
203
215
* @param string $path [optional]
204
216
* @return bool
205
- * @throws \Magento\Framework\Exception\ FileSystemException
217
+ * @throws FileSystemException
206
218
* @throws ValidatorException
207
219
*/
208
220
public function isExist ($ path = null )
209
221
{
210
222
$ this ->validatePath ($ path );
211
223
212
- return $ this ->driver ->isExists (
213
- $ this ->driver ->getRealPathSafety ($ this ->driver ->getAbsolutePath ($ this ->path , $ path ))
214
- );
224
+ return $ this ->driver ->isExists ($ this ->driver ->getAbsolutePath ($ this ->path , $ path ));
215
225
}
216
226
217
227
/**
218
228
* Gathers the statistics of the given path
219
229
*
220
230
* @param string $path
221
- * @return arrays
222
- * @throws \Magento\Framework\Exception\ FileSystemException
231
+ * @return array
232
+ * @throws FileSystemException
223
233
* @throws ValidatorException
224
234
*/
225
235
public function stat ($ path )
@@ -234,7 +244,7 @@ public function stat($path)
234
244
*
235
245
* @param string $path [optional]
236
246
* @return bool
237
- * @throws \Magento\Framework\Exception\ FileSystemException
247
+ * @throws FileSystemException
238
248
* @throws ValidatorException
239
249
*/
240
250
public function isReadable ($ path = null )
@@ -284,6 +294,7 @@ public function readFile($path, $flag = null, $context = null)
284
294
* Check whether given path is file
285
295
*
286
296
* @param string $path
297
+ * @throws FileSystemException
287
298
* @throws ValidatorException
288
299
* @return bool
289
300
*/
@@ -298,6 +309,7 @@ public function isFile($path)
298
309
* Check whether given path is directory
299
310
*
300
311
* @param string $path [optional]
312
+ * @throws FileSystemException
301
313
* @throws ValidatorException
302
314
* @return bool
303
315
*/
0 commit comments