1 | <?php |
||
22 | abstract class FileModel extends Model |
||
23 | { |
||
24 | /** |
||
25 | * Get the table. |
||
26 | * |
||
27 | * @abstract |
||
28 | * |
||
29 | * @return string |
||
30 | */ |
||
31 | abstract protected function getTable(); |
||
32 | |||
33 | /** |
||
34 | * Define the foreign key. |
||
35 | * |
||
36 | * @abstract |
||
37 | * |
||
38 | * @return string |
||
39 | */ |
||
40 | abstract protected function getForeignKey(); |
||
41 | |||
42 | /** |
||
43 | * Get the path prefix. |
||
44 | * |
||
45 | * @abstract |
||
46 | * |
||
47 | * @return string |
||
48 | */ |
||
49 | abstract protected function getPathPrefix(); |
||
50 | |||
51 | /** |
||
52 | * Fire file creation event. |
||
53 | * |
||
54 | * @abstract |
||
55 | * |
||
56 | * @param int $file_id |
||
57 | */ |
||
58 | abstract protected function fireCreationEvent($file_id); |
||
59 | |||
60 | /** |
||
61 | * Get PicoDb query to get all files. |
||
62 | * |
||
63 | * @return \PicoDb\Table |
||
64 | */ |
||
65 | protected function getQuery() |
||
83 | |||
84 | /** |
||
85 | * Get a file by the id. |
||
86 | * |
||
87 | * @param int $file_id File id |
||
88 | * |
||
89 | * @return array |
||
90 | */ |
||
91 | public function getById($file_id) |
||
95 | |||
96 | /** |
||
97 | * Get all files. |
||
98 | * |
||
99 | * @param int $id |
||
100 | * |
||
101 | * @return array |
||
102 | */ |
||
103 | public function getAll($id) |
||
107 | |||
108 | /** |
||
109 | * Get all images. |
||
110 | * |
||
111 | * @param int $id |
||
112 | * |
||
113 | * @return array |
||
114 | */ |
||
115 | public function getAllImages($id) |
||
119 | |||
120 | /** |
||
121 | * Get all files without images. |
||
122 | * |
||
123 | * @param int $id |
||
124 | * |
||
125 | * @return array |
||
126 | */ |
||
127 | public function getAllDocuments($id) |
||
131 | |||
132 | /** |
||
133 | * Create a file entry in the database. |
||
134 | * |
||
135 | * @param int $foreign_key_id Foreign key |
||
136 | * @param string $name Filename |
||
137 | * @param string $path Path on the disk |
||
138 | * @param int $size File size |
||
139 | * |
||
140 | * @return bool|int |
||
141 | */ |
||
142 | public function create($foreign_key_id, $name, $path, $size) |
||
165 | |||
166 | /** |
||
167 | * Remove all files. |
||
168 | * |
||
169 | * @param int $id |
||
170 | * |
||
171 | * @return bool |
||
172 | */ |
||
173 | public function removeAll($id) |
||
184 | |||
185 | /** |
||
186 | * Remove a file. |
||
187 | * |
||
188 | * @param int $file_id File id |
||
189 | * |
||
190 | * @return bool |
||
191 | */ |
||
192 | public function remove($file_id) |
||
209 | |||
210 | /** |
||
211 | * Check if a filename is an image (file types that can be shown as thumbnail). |
||
212 | * |
||
213 | * @param string $filename Filename |
||
214 | * |
||
215 | * @return bool |
||
216 | */ |
||
217 | public function isImage($filename) |
||
231 | |||
232 | /** |
||
233 | * Generate the path for a thumbnails. |
||
234 | * |
||
235 | * @param string $key Storage key |
||
236 | * |
||
237 | * @return string |
||
238 | */ |
||
239 | public function getThumbnailPath($key) |
||
243 | |||
244 | /** |
||
245 | * Generate the path for a new filename. |
||
246 | * |
||
247 | * @param int $id Foreign key |
||
248 | * @param string $filename Filename |
||
249 | * |
||
250 | * @return string |
||
251 | */ |
||
252 | public function generatePath($id, $filename) |
||
256 | |||
257 | /** |
||
258 | * Upload multiple files. |
||
259 | * |
||
260 | * @param int $id |
||
261 | * @param array $files |
||
262 | * |
||
263 | * @return bool |
||
264 | */ |
||
265 | public function uploadFiles($id, array $files) |
||
290 | |||
291 | /** |
||
292 | * Upload a file. |
||
293 | * |
||
294 | * @param int $id |
||
295 | * @param array $file |
||
296 | * |
||
297 | * @throws Exception |
||
298 | */ |
||
299 | public function uploadFile($id, array $file) |
||
314 | |||
315 | /** |
||
316 | * Handle file upload (base64 encoded content). |
||
317 | * |
||
318 | * @param int $id |
||
319 | * @param string $original_filename |
||
320 | * @param string $blob |
||
321 | * |
||
322 | * @return bool|int |
||
323 | */ |
||
324 | public function uploadContent($id, $original_filename, $blob) |
||
352 | |||
353 | /** |
||
354 | * Generate thumbnail from a blob. |
||
355 | * |
||
356 | * @param string $destination_filename |
||
357 | * @param string $data |
||
358 | */ |
||
359 | public function generateThumbnailFromData($destination_filename, &$data) |
||
367 | |||
368 | /** |
||
369 | * Generate thumbnail from a local file. |
||
370 | * |
||
371 | * @param string $uploaded_filename |
||
372 | * @param string $destination_filename |
||
373 | */ |
||
374 | public function generateThumbnailFromFile($uploaded_filename, $destination_filename) |
||
382 | } |
||
383 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.