1 | <?php |
||
28 | class File extends Node |
||
29 | { |
||
30 | use PrototypedBindings; |
||
31 | |||
32 | const MODEL_ID = 'files'; |
||
33 | |||
34 | const MIME = 'mime'; |
||
35 | const SIZE = 'size'; |
||
36 | const EXTENSION = 'extension'; |
||
37 | const DESCRIPTION = 'description'; |
||
38 | const HTTP_FILE = 'file'; |
||
39 | |||
40 | /** |
||
41 | * Size of the file. |
||
42 | * |
||
43 | * @var int |
||
44 | */ |
||
45 | public $size; |
||
46 | |||
47 | /** |
||
48 | * MIME type of the file. |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | public $mime; |
||
53 | |||
54 | /** |
||
55 | * File extension, including the dot ".". |
||
56 | * |
||
57 | * @var string |
||
58 | */ |
||
59 | public $extension = ''; |
||
60 | |||
61 | /** |
||
62 | * Description of the file. |
||
63 | * |
||
64 | * @var string |
||
65 | */ |
||
66 | public $description = ''; |
||
67 | |||
68 | /** |
||
69 | * @return Pathname|null |
||
70 | */ |
||
71 | protected function get_pathname() |
||
87 | |||
88 | /** |
||
89 | * @var string |
||
90 | */ |
||
91 | protected $short_hash; |
||
92 | |||
93 | /** |
||
94 | * Returns the short hash of the file. |
||
95 | * |
||
96 | * @return string |
||
97 | */ |
||
98 | protected function get_short_hash() |
||
102 | |||
103 | /** |
||
104 | * @return Storage\FileStorage |
||
105 | */ |
||
106 | protected function get_file_storage() |
||
110 | |||
111 | /** |
||
112 | * If {@link HTTP_FILE} is defined, the {@link HTTPFile} instance is used to |
||
113 | * set the {@link $mime}, {@link $size} and {@link $extension} properties. |
||
114 | * The {@link $title} property is updated as well if it is empty. |
||
115 | * |
||
116 | * After the record is saved, the {@link HTTP_FILE} property is removed. |
||
117 | * |
||
118 | * @inheritdoc |
||
119 | */ |
||
120 | public function save(array $options = []) |
||
143 | |||
144 | public function delete() |
||
155 | |||
156 | /** |
||
157 | * Begins saving the HTTP file. |
||
158 | * |
||
159 | * @param HTTPFile $file |
||
160 | */ |
||
161 | protected function save_file_before(HTTPFile $file) |
||
173 | |||
174 | /** |
||
175 | * Finishes saving the HTTP file. |
||
176 | * |
||
177 | * @param HTTPFile $file |
||
178 | */ |
||
179 | protected function save_file_after(HTTPFile $file) |
||
191 | |||
192 | /** |
||
193 | * Returns a URL for this record. |
||
194 | * |
||
195 | * @param string $type |
||
196 | * |
||
197 | * @return \ICanBoogie\Routing\FormattedRoute|string |
||
198 | */ |
||
199 | public function url($type = 'view') |
||
225 | } |
||
226 |