1 | <?php namespace Arcanesoft\Media; |
||
19 | class Media implements MediaContract |
||
20 | { |
||
21 | /* ----------------------------------------------------------------- |
||
22 | | Constants |
||
23 | | ----------------------------------------------------------------- |
||
24 | */ |
||
25 | |||
26 | const VERSION = '2.2.2'; |
||
27 | |||
28 | /* ----------------------------------------------------------------- |
||
29 | | Properties |
||
30 | | ----------------------------------------------------------------- |
||
31 | */ |
||
32 | |||
33 | /** |
||
34 | * The application instance. |
||
35 | * |
||
36 | * @var \Illuminate\Contracts\Foundation\Application |
||
37 | */ |
||
38 | protected $app; |
||
39 | |||
40 | /* ----------------------------------------------------------------- |
||
41 | | Constructor |
||
42 | | ----------------------------------------------------------------- |
||
43 | */ |
||
44 | |||
45 | /** |
||
46 | * Media constructor. |
||
47 | * |
||
48 | * @param \Illuminate\Contracts\Foundation\Application $app |
||
49 | */ |
||
50 | 39 | public function __construct(Application $app) |
|
54 | |||
55 | /* ----------------------------------------------------------------- |
||
56 | | Getters & Setters |
||
57 | | ----------------------------------------------------------------- |
||
58 | */ |
||
59 | |||
60 | /** |
||
61 | * Get the Filesystem Manager instance. |
||
62 | * |
||
63 | * @return \Illuminate\Contracts\Filesystem\Factory |
||
64 | */ |
||
65 | 30 | public function filesystem() |
|
69 | |||
70 | /** |
||
71 | * Get the Config Repository. |
||
72 | * |
||
73 | * @return \Illuminate\Contracts\Config\Repository |
||
74 | */ |
||
75 | 36 | protected function config() |
|
79 | |||
80 | /** |
||
81 | * Get the default disk name. |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | 30 | public function getDefaultDiskName() |
|
89 | |||
90 | /** |
||
91 | * Get excluded directories. |
||
92 | * |
||
93 | * @return array |
||
94 | */ |
||
95 | 24 | public function getExcludedDirectories() |
|
101 | |||
102 | /** |
||
103 | * Get excluded files. |
||
104 | * |
||
105 | * @return array |
||
106 | */ |
||
107 | 18 | public function getExcludedFiles() |
|
111 | |||
112 | /* ----------------------------------------------------------------- |
||
113 | | Main Methods |
||
114 | | ----------------------------------------------------------------- |
||
115 | */ |
||
116 | |||
117 | /** |
||
118 | * Get a filesystem adapter. |
||
119 | * |
||
120 | * @param string|null $driver |
||
121 | * |
||
122 | * @return \Illuminate\Filesystem\FilesystemAdapter|\Illuminate\Contracts\Filesystem\Filesystem |
||
123 | */ |
||
124 | 30 | public function disk($driver = null) |
|
128 | |||
129 | /** |
||
130 | * Get all the directories & files from a given location. |
||
131 | * |
||
132 | * @param string $directory |
||
133 | * |
||
134 | * @return array |
||
135 | */ |
||
136 | 3 | public function all($directory = '/') |
|
148 | |||
149 | /** |
||
150 | * Get all of the directories within a given directory. |
||
151 | * |
||
152 | * @param string $directory |
||
153 | * |
||
154 | * @return \Arcanesoft\Media\Entities\DirectoryCollection |
||
155 | */ |
||
156 | 12 | public function directories($directory) |
|
170 | |||
171 | /** |
||
172 | * Get a collection of all files in a directory. |
||
173 | * |
||
174 | * @param string $directory |
||
175 | * |
||
176 | * @return \Arcanesoft\Media\Entities\FileCollection |
||
177 | */ |
||
178 | 15 | public function files($directory) |
|
199 | |||
200 | /** |
||
201 | * Get the file details. |
||
202 | * |
||
203 | * @param string $path |
||
204 | * |
||
205 | * @return array |
||
206 | */ |
||
207 | 6 | public function file($path) |
|
215 | |||
216 | /** |
||
217 | * Store an array of files. |
||
218 | * |
||
219 | * @param string $directory |
||
220 | * @param array $files |
||
221 | */ |
||
222 | 3 | public function storeMany($directory, array $files) |
|
228 | |||
229 | /** |
||
230 | * Store a file. |
||
231 | * |
||
232 | * @param string $directory |
||
233 | * @param \Illuminate\Http\UploadedFile $file |
||
234 | * |
||
235 | * @return string|false |
||
236 | */ |
||
237 | 6 | public function store($directory, UploadedFile $file) |
|
241 | |||
242 | /** |
||
243 | * Create a directory. |
||
244 | * |
||
245 | * @param string $path |
||
246 | * |
||
247 | * @return bool |
||
248 | */ |
||
249 | 6 | public function makeDirectory($path) |
|
253 | |||
254 | /** |
||
255 | * Delete a directory. |
||
256 | * |
||
257 | * @param string $directory |
||
258 | * |
||
259 | * @return bool |
||
260 | */ |
||
261 | 6 | public function deleteDirectory($directory) |
|
265 | |||
266 | /** |
||
267 | * Delete a file. |
||
268 | * |
||
269 | * @param string $path |
||
270 | * |
||
271 | * @return bool |
||
272 | */ |
||
273 | 3 | public function deleteFile($path) |
|
277 | |||
278 | /** |
||
279 | * Move a file to a new location. |
||
280 | * |
||
281 | * @param string $from |
||
282 | * @param string $to |
||
283 | * |
||
284 | * @return bool |
||
285 | */ |
||
286 | 3 | public function move($from, $to) |
|
290 | |||
291 | /* ----------------------------------------------------------------- |
||
292 | | Check Methods |
||
293 | | ----------------------------------------------------------------- |
||
294 | */ |
||
295 | |||
296 | /** |
||
297 | * Determine if a file/directory exists. |
||
298 | * |
||
299 | * @param string $path |
||
300 | * |
||
301 | * @return bool |
||
302 | */ |
||
303 | 24 | public function exists($path) |
|
307 | |||
308 | /** |
||
309 | * Check if the directory is excluded. |
||
310 | * |
||
311 | * @param string $directory |
||
312 | * |
||
313 | * @return bool |
||
314 | */ |
||
315 | 21 | public function isExcludedDirectory($directory) |
|
323 | |||
324 | /* ----------------------------------------------------------------- |
||
325 | | Other Methods |
||
326 | | ----------------------------------------------------------------- |
||
327 | */ |
||
328 | |||
329 | /** |
||
330 | * Check the given directory location. |
||
331 | * |
||
332 | * @param string &$directory |
||
333 | * |
||
334 | * @throws \Arcanesoft\Media\Exceptions\DirectoryNotFound |
||
335 | * @throws \Arcanesoft\Media\Exceptions\AccessNotAllowed |
||
336 | */ |
||
337 | 24 | protected function checkDirectory(&$directory) |
|
344 | |||
345 | /** |
||
346 | * Check if the directory exists. |
||
347 | * |
||
348 | * @param string $directory |
||
349 | * |
||
350 | * @throws \Arcanesoft\Media\Exceptions\DirectoryNotFound |
||
351 | */ |
||
352 | 24 | protected function checkDirectoryExists($directory) |
|
358 | |||
359 | /** |
||
360 | * Check if can access the directory. |
||
361 | * |
||
362 | * @param string $directory |
||
363 | * |
||
364 | * @throws \Arcanesoft\Media\Exceptions\AccessNotAllowed |
||
365 | */ |
||
366 | 21 | protected function checkDirectoryAccess($directory) |
|
372 | } |
||
373 |