1 | <?php |
||||||
2 | |||||||
3 | namespace UniSharp\LaravelFilemanager; |
||||||
4 | |||||||
5 | use Illuminate\Support\Facades\Storage; |
||||||
6 | |||||||
7 | class LfmStorageRepository |
||||||
8 | { |
||||||
9 | private $disk; |
||||||
10 | private $path; |
||||||
11 | private $helper; |
||||||
12 | |||||||
13 | public function __construct($storage_path, $helper) |
||||||
14 | { |
||||||
15 | $this->helper = $helper; |
||||||
16 | $this->disk = Storage::disk($this->helper->config('disk')); |
||||||
17 | $this->path = $storage_path; |
||||||
18 | } |
||||||
19 | |||||||
20 | public function __call($function_name, $arguments) |
||||||
21 | { |
||||||
22 | // TODO: check function exists |
||||||
23 | return $this->disk->$function_name($this->path, ...$arguments); |
||||||
24 | } |
||||||
25 | |||||||
26 | public function rootPath() |
||||||
27 | { |
||||||
28 | return $this->disk->path(''); |
||||||
29 | } |
||||||
30 | |||||||
31 | public function move($new_lfm_path) |
||||||
32 | { |
||||||
33 | return $this->disk->move($this->path, $new_lfm_path->path('storage')); |
||||||
34 | } |
||||||
35 | |||||||
36 | public function save($file) |
||||||
37 | { |
||||||
38 | $nameint = strripos($this->path, "/"); |
||||||
39 | $nameclean = substr($this->path, $nameint + 1); |
||||||
40 | $pathclean = substr_replace($this->path, "", $nameint); |
||||||
41 | $this->disk->putFileAs($pathclean, $file, $nameclean, 'public'); |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
42 | } |
||||||
43 | |||||||
44 | public function url($path) |
||||||
45 | { |
||||||
46 | return $this->disk->url($path); |
||||||
47 | } |
||||||
48 | |||||||
49 | public function makeDirectory() |
||||||
50 | { |
||||||
51 | $this->disk->makeDirectory($this->path, ...func_get_args()); |
||||||
0 ignored issues
–
show
The call to
Illuminate\Filesystem\Fi...dapter::makeDirectory() has too many arguments starting with func_get_args() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. ![]() |
|||||||
52 | |||||||
53 | // some filesystems (e.g. Google Storage, S3?) don't let you set ACLs on directories (because they don't exist) |
||||||
54 | // https://cloud.google.com/storage/docs/naming#object-considerations |
||||||
55 | if ($this->disk->has($this->path)) { |
||||||
0 ignored issues
–
show
The method
has() does not exist on Illuminate\Contracts\Filesystem\Filesystem . It seems like you code against a sub-type of Illuminate\Contracts\Filesystem\Filesystem such as Illuminate\Filesystem\FilesystemAdapter .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
56 | $this->disk->setVisibility($this->path, 'public'); |
||||||
57 | } |
||||||
58 | } |
||||||
59 | |||||||
60 | public function extension() |
||||||
61 | { |
||||||
62 | setlocale(LC_ALL, 'en_US.UTF-8'); |
||||||
63 | return pathinfo($this->path, PATHINFO_EXTENSION); |
||||||
64 | } |
||||||
65 | } |
||||||
66 |