1 | <?php namespace Arcanesoft\Media\Http\Controllers\Admin; |
||
16 | class ApiController |
||
17 | { |
||
18 | /* ----------------------------------------------------------------- |
||
19 | | Traits |
||
20 | | ----------------------------------------------------------------- |
||
21 | */ |
||
22 | |||
23 | use JsonResponses, |
||
24 | AuthorizesRequests; |
||
25 | |||
26 | /* ----------------------------------------------------------------- |
||
27 | | Properties |
||
28 | | ----------------------------------------------------------------- |
||
29 | */ |
||
30 | |||
31 | /** |
||
32 | * The media instance. |
||
33 | * |
||
34 | * @var \Arcanesoft\Media\Contracts\Media |
||
35 | */ |
||
36 | protected $media; |
||
37 | |||
38 | /* ----------------------------------------------------------------- |
||
39 | | Constructor |
||
40 | | ----------------------------------------------------------------- |
||
41 | */ |
||
42 | |||
43 | /** |
||
44 | * ApiController constructor. |
||
45 | * |
||
46 | * @param \Arcanesoft\Media\Contracts\Media $media |
||
47 | */ |
||
48 | 51 | public function __construct(Media $media) |
|
52 | |||
53 | /* ----------------------------------------------------------------- |
||
54 | | Main Methods |
||
55 | | ----------------------------------------------------------------- |
||
56 | */ |
||
57 | |||
58 | /** |
||
59 | * Get the the media files. |
||
60 | * |
||
61 | * @param \Illuminate\Http\Request $request |
||
62 | * |
||
63 | * @return \Illuminate\Http\JsonResponse |
||
64 | */ |
||
65 | 6 | public function getAll(Request $request) |
|
75 | |||
76 | /** |
||
77 | * Upload a media file. |
||
78 | * |
||
79 | * @param \Illuminate\Http\Request $request |
||
80 | * |
||
81 | * @return \Illuminate\Http\JsonResponse |
||
82 | */ |
||
83 | 6 | public function uploadMedia(Request $request) |
|
108 | |||
109 | /** |
||
110 | * Create a directory. |
||
111 | * |
||
112 | * @param \Illuminate\Http\Request $request |
||
113 | * |
||
114 | * @return \Illuminate\Http\JsonResponse |
||
115 | */ |
||
116 | 6 | public function createDirectory(Request $request) |
|
138 | |||
139 | 12 | public function renameMedia(Request $request) |
|
175 | |||
176 | 9 | public function deleteMedia(Request $request) |
|
197 | |||
198 | 3 | public function moveLocations(Request $request) |
|
210 | |||
211 | 6 | public function moveMedia(Request $request) |
|
231 | |||
232 | /* ----------------------------------------------------------------- |
||
233 | | Other Methods |
||
234 | | ----------------------------------------------------------------- |
||
235 | */ |
||
236 | |||
237 | /** |
||
238 | * Get the destinations paths. |
||
239 | * |
||
240 | * @param string $name |
||
241 | * @param string $location |
||
242 | * |
||
243 | * @return \Arcanesoft\Media\Entities\DirectoryCollection |
||
244 | */ |
||
245 | 3 | private function getDestinations($name, $location) |
|
260 | |||
261 | /** |
||
262 | * Perform the media movement. |
||
263 | * |
||
264 | * @param string $type |
||
265 | * @param string $location |
||
266 | * @param string $oldName |
||
267 | * @param string $newName |
||
268 | * |
||
269 | * @return bool|string |
||
270 | */ |
||
271 | 9 | private function performMoveMedia($type, $location, $oldName, $newName) |
|
286 | |||
287 | /** |
||
288 | * Move file. |
||
289 | * |
||
290 | * @param string $location |
||
291 | * @param string $location |
||
292 | * @param string $from |
||
293 | * @param string $newName |
||
294 | * |
||
295 | * @return string |
||
296 | */ |
||
297 | 3 | private function moveFile($from, $location, $newName) |
|
306 | |||
307 | /** |
||
308 | * Move directory. |
||
309 | * |
||
310 | * @param string $from |
||
311 | * @param string $location |
||
312 | * @param string $newName |
||
313 | * |
||
314 | * @return string |
||
315 | */ |
||
316 | 3 | private function moveDirectory($from, $location, $newName) |
|
324 | |||
325 | /** |
||
326 | * Perform the media deletion. |
||
327 | * |
||
328 | * @param string $type |
||
329 | * @param string $path |
||
330 | * |
||
331 | * @return bool |
||
332 | */ |
||
333 | 6 | private function performDeleteMedia($type, $path) |
|
346 | } |
||
347 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.