1 | <?php |
||||
2 | |||||
3 | |||||
4 | namespace NovaChunkedVideo; |
||||
5 | |||||
6 | use Laravel\Nova\Http\Requests\NovaRequest; |
||||
7 | |||||
8 | trait HasChunkFolder |
||||
9 | { |
||||
10 | |||||
11 | /** |
||||
12 | * Temporary chunk folder |
||||
13 | * |
||||
14 | * @var string |
||||
15 | */ |
||||
16 | protected string $chunksFolder; |
||||
17 | |||||
18 | /** |
||||
19 | * The callback used to store file. |
||||
20 | * |
||||
21 | * @var callable |
||||
22 | */ |
||||
23 | public ?\Closure $storeFileCallback = null; |
||||
24 | |||||
25 | /** |
||||
26 | * Set chunk folder |
||||
27 | * |
||||
28 | * @param string $chunksFolder |
||||
29 | * |
||||
30 | * @return $this |
||||
31 | */ |
||||
32 | 1 | public function chunksFolder(string $chunksFolder) |
|||
33 | { |
||||
34 | 1 | $this->chunksFolder = $chunksFolder; |
|||
35 | |||||
36 | 1 | return $this; |
|||
37 | } |
||||
38 | |||||
39 | /** |
||||
40 | * Get chunk folder |
||||
41 | * |
||||
42 | * @return string |
||||
43 | */ |
||||
44 | 3 | public function getChunksFolder(): string |
|||
45 | { |
||||
46 | 3 | return $this->chunksFolder; |
|||
47 | } |
||||
48 | |||||
49 | /** |
||||
50 | * Specify the callback that should be used to save file. |
||||
51 | * |
||||
52 | * @param callable $storeFileCallback |
||||
53 | * |
||||
54 | * @return $this |
||||
55 | */ |
||||
56 | 13 | public function store(callable $storeFileCallback) |
|||
57 | { |
||||
58 | 13 | $this->storeFileCallback = $storeFileCallback; |
|||
59 | |||||
60 | 13 | return $this; |
|||
61 | } |
||||
62 | |||||
63 | /** |
||||
64 | * Store file |
||||
65 | * |
||||
66 | * @param NovaRequest $request |
||||
67 | * @param $filePath |
||||
68 | * |
||||
69 | * @return string|null |
||||
70 | */ |
||||
71 | 2 | public function storeFile(NovaRequest $request, $filePath): ?string |
|||
72 | { |
||||
73 | 2 | return call_user_func($this->storeFileCallback, $filePath, $this->getStorageDisk(), $this->resource, $this->attribute, $request); |
|||
0 ignored issues
–
show
Bug
introduced
by
![]() It seems like
$this->storeFileCallback can also be of type null ; however, parameter $callback of call_user_func() does only seem to accept callable , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
74 | } |
||||
75 | } |
||||
76 |