1 | <?php namespace Arcanesoft\Media; |
||
16 | class Media implements MediaContract |
||
17 | { |
||
18 | /* ----------------------------------------------------------------- |
||
19 | | Properties |
||
20 | | ----------------------------------------------------------------- |
||
21 | */ |
||
22 | /** |
||
23 | * The application instance. |
||
24 | * |
||
25 | * @var \Illuminate\Contracts\Foundation\Application |
||
26 | */ |
||
27 | protected $app; |
||
28 | |||
29 | /* ----------------------------------------------------------------- |
||
30 | | Constructor |
||
31 | | ----------------------------------------------------------------- |
||
32 | */ |
||
33 | /** |
||
34 | * Media constructor. |
||
35 | * |
||
36 | * @param \Illuminate\Contracts\Foundation\Application $app |
||
37 | */ |
||
38 | 6 | public function __construct(Application $app) |
|
42 | |||
43 | /* ----------------------------------------------------------------- |
||
44 | | Getters & Setters |
||
45 | | ----------------------------------------------------------------- |
||
46 | */ |
||
47 | /** |
||
48 | * Get the Filesystem Manager instance. |
||
49 | * |
||
50 | * @return \Illuminate\Contracts\Filesystem\Factory |
||
51 | */ |
||
52 | 3 | public function filesystem() |
|
56 | |||
57 | /** |
||
58 | * Get the Config Repository. |
||
59 | * |
||
60 | * @return \Illuminate\Contracts\Config\Repository |
||
61 | */ |
||
62 | 3 | protected function config() |
|
66 | |||
67 | /** |
||
68 | * Get the default disk name. |
||
69 | * |
||
70 | * @return string |
||
71 | */ |
||
72 | 3 | public function getDefaultDiskName() |
|
76 | |||
77 | /** |
||
78 | * Get excluded directories. |
||
79 | * |
||
80 | * @return array |
||
81 | */ |
||
82 | public function getExcludedDirectories() |
||
88 | |||
89 | /** |
||
90 | * Get excluded files. |
||
91 | * |
||
92 | * @return array |
||
93 | */ |
||
94 | public function getExcludedFiles() |
||
98 | |||
99 | /* ----------------------------------------------------------------- |
||
100 | | Main Methods |
||
101 | | ----------------------------------------------------------------- |
||
102 | */ |
||
103 | /** |
||
104 | * Get a filesystem adapter. |
||
105 | * |
||
106 | * @param string|null $driver |
||
107 | * |
||
108 | * @return \Illuminate\Filesystem\FilesystemAdapter|\Illuminate\Contracts\Filesystem\Filesystem |
||
109 | */ |
||
110 | 3 | public function disk($driver = null) |
|
114 | |||
115 | /** |
||
116 | * Get the default filesystem adapter. |
||
117 | * |
||
118 | * @return \Illuminate\Filesystem\FilesystemAdapter|\Illuminate\Contracts\Filesystem\Filesystem |
||
119 | */ |
||
120 | 3 | public function defaultDisk() |
|
124 | |||
125 | /** |
||
126 | * Get all the directories & files from a given location. |
||
127 | * |
||
128 | * @param string $directory |
||
129 | * |
||
130 | * @return array |
||
131 | */ |
||
132 | public function all($directory) |
||
144 | |||
145 | /** |
||
146 | * Get all of the directories within a given directory. |
||
147 | * |
||
148 | * @param string $directory |
||
149 | * |
||
150 | * @return \Arcanesoft\Media\Entities\DirectoryCollection |
||
151 | */ |
||
152 | public function directories($directory) |
||
166 | |||
167 | /** |
||
168 | * Get a collection of all files in a directory. |
||
169 | * |
||
170 | * @param string $directory |
||
171 | * |
||
172 | * @return \Arcanesoft\Media\Entities\FileCollection |
||
173 | */ |
||
174 | public function files($directory) |
||
196 | |||
197 | /** |
||
198 | * Store an array of files. |
||
199 | * |
||
200 | * @param string $directory |
||
201 | * @param array $files |
||
202 | */ |
||
203 | public function storeMany($directory, array $files) |
||
209 | |||
210 | /** |
||
211 | * Store a file. |
||
212 | * |
||
213 | * @param string $directory |
||
214 | * @param \Illuminate\Http\UploadedFile $file |
||
215 | * |
||
216 | * @return string|false |
||
217 | */ |
||
218 | public function store($directory, UploadedFile $file) |
||
222 | |||
223 | /** |
||
224 | * Create a directory. |
||
225 | * |
||
226 | * @param string $path |
||
227 | * |
||
228 | * @return bool |
||
229 | */ |
||
230 | public function makeDirectory($path) |
||
234 | |||
235 | /** |
||
236 | * Move a file to a new location. |
||
237 | * |
||
238 | * @param string $from |
||
239 | * @param string $to |
||
240 | * |
||
241 | * @return bool |
||
242 | */ |
||
243 | public function move($from, $to) |
||
247 | |||
248 | /* ----------------------------------------------------------------- |
||
249 | | Check Methods |
||
250 | | ----------------------------------------------------------------- |
||
251 | */ |
||
252 | /** |
||
253 | * Determine if a file/directory exists. |
||
254 | * |
||
255 | * @param string $path |
||
256 | * |
||
257 | * @return bool |
||
258 | */ |
||
259 | public function exists($path) |
||
263 | |||
264 | /** |
||
265 | * Check if the directory is excluded. |
||
266 | * |
||
267 | * @param string $directory |
||
268 | * |
||
269 | * @return bool |
||
270 | */ |
||
271 | public function isExcludedDirectory($directory) |
||
279 | |||
280 | /* ----------------------------------------------------------------- |
||
281 | | Other Methods |
||
282 | | ----------------------------------------------------------------- |
||
283 | */ |
||
284 | /** |
||
285 | * Check the given directory location. |
||
286 | * |
||
287 | * @param string &$directory |
||
288 | * |
||
289 | * @throws \Arcanesoft\Media\Exceptions\DirectoryNotFound |
||
290 | * @throws \Arcanesoft\Media\Exceptions\AccessNotAllowed |
||
291 | */ |
||
292 | protected function checkDirectory(&$directory) |
||
299 | |||
300 | /** |
||
301 | * Check if the directory exists. |
||
302 | * |
||
303 | * @param string $directory |
||
304 | * |
||
305 | * @throws \Arcanesoft\Media\Exceptions\DirectoryNotFound |
||
306 | */ |
||
307 | protected function checkDirectoryExists($directory) |
||
313 | |||
314 | /** |
||
315 | * Check if can access the directory. |
||
316 | * |
||
317 | * @param string $directory |
||
318 | * |
||
319 | * @throws \Arcanesoft\Media\Exceptions\AccessNotAllowed |
||
320 | */ |
||
321 | protected function checkDirectoryAccess($directory) |
||
327 | } |
||
328 |