1 | <?php |
||
36 | class File extends \yii\db\ActiveRecord |
||
37 | { |
||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | public $path; |
||
42 | /** |
||
43 | * @var Storage |
||
44 | */ |
||
45 | private $storage; |
||
46 | |||
47 | /** |
||
48 | * @inheritdoc |
||
49 | * @codeCoverageIgnore |
||
50 | * @internal |
||
51 | */ |
||
52 | public static function tableName() |
||
56 | |||
57 | /** |
||
58 | * @inheritdoc |
||
59 | * @codeCoverageIgnore |
||
60 | * @internal |
||
61 | */ |
||
62 | public function attributeLabels() |
||
80 | |||
81 | /** |
||
82 | * @inheritdoc |
||
83 | * @internal |
||
84 | */ |
||
85 | 35 | public function behaviors() |
|
96 | |||
97 | /** |
||
98 | * @inheritdoc |
||
99 | * @codeCoverageIgnore |
||
100 | * @internal |
||
101 | */ |
||
102 | public function events() |
||
108 | |||
109 | /** |
||
110 | * @internal |
||
111 | */ |
||
112 | 32 | public function beforeSave($insert) |
|
136 | |||
137 | 31 | private function fillMetaInfo() |
|
150 | |||
151 | 31 | private function getExtensionByMimeType($mimeType) |
|
172 | |||
173 | /** |
||
174 | * Set a storage |
||
175 | * |
||
176 | * @param Storage $storage The Strorage for the file |
||
177 | * @return string |
||
178 | */ |
||
179 | 32 | public function setStorage(Storage $storage) |
|
186 | |||
187 | /** |
||
188 | * Get a storage |
||
189 | * |
||
190 | * @return string |
||
191 | * @throws InvalidParamException |
||
192 | */ |
||
193 | 33 | public function getStorage() |
|
201 | |||
202 | /** |
||
203 | * Generate a name |
||
204 | * |
||
205 | * @return string |
||
206 | */ |
||
207 | 31 | public function generateName() |
|
212 | |||
213 | /** |
||
214 | * Checks whether the file is protected |
||
215 | * |
||
216 | * @return bool |
||
217 | */ |
||
218 | 32 | public function isProtected() |
|
222 | |||
223 | /** |
||
224 | * Checks whether the file is unprotected |
||
225 | * |
||
226 | * @return bool |
||
227 | */ |
||
228 | 3 | public function isUnprotected() |
|
232 | |||
233 | /** |
||
234 | * Checks whether the file is temp |
||
235 | * |
||
236 | * @return bool |
||
237 | */ |
||
238 | 12 | public function isTmp() |
|
242 | |||
243 | /** |
||
244 | * Get date create of file in format `Ym` |
||
245 | * |
||
246 | * @return string |
||
247 | */ |
||
248 | 31 | public function getDateOfFile() |
|
256 | |||
257 | /** |
||
258 | * Checks whether the owner of the file |
||
259 | * |
||
260 | * @param int $ownerId The id of the owner |
||
261 | * @param int $ownerType The type of the owner |
||
262 | * @return bool |
||
263 | */ |
||
264 | 20 | public function isOwner($ownerId, $ownerType) |
|
272 | |||
273 | /** |
||
274 | * Find all by owner |
||
275 | * |
||
276 | * @param int $ownerId The id of the owner |
||
277 | * @param int $ownerType The type of the owner |
||
278 | * @return array |
||
279 | */ |
||
280 | 18 | public static function findAllByOwner($ownerId, $ownerType) |
|
287 | |||
288 | /** |
||
289 | * Find one by owner |
||
290 | * |
||
291 | * @param int $ownerId The id of the owner |
||
292 | * @param int $ownerType The type of the owner |
||
293 | * @return File|null |
||
294 | */ |
||
295 | 1 | public static function findOneByOwner($ownerId, $ownerType) |
|
301 | |||
302 | /** |
||
303 | * Delete by owner |
||
304 | * |
||
305 | * @param Storage $storage The storage of the file |
||
306 | * @param int $ownerId The id of the owner |
||
307 | * @param int $ownerType The type of the owner |
||
308 | */ |
||
309 | 3 | public function deleteByOwner($storage, $ownerId, $ownerType) |
|
318 | |||
319 | /** |
||
320 | * Deleting a file from the db and from the file system |
||
321 | * @internal |
||
322 | * |
||
323 | * @return bool |
||
324 | */ |
||
325 | 7 | public function beforeDelete() |
|
330 | } |
||
331 |