itstructure /
yii2-multi-format-uploader
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Itstructure\MFUploader\interfaces; |
||
| 4 | |||
| 5 | use yii\web\UploadedFile; |
||
| 6 | use yii\base\InvalidConfigException; |
||
| 7 | use Itstructure\MFUploader\models\Mediafile; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Interface UploadModelInterface |
||
| 11 | * |
||
| 12 | * @package Itstructure\MFUploader\interfaces |
||
| 13 | * |
||
| 14 | * @author Andrey Girnik <[email protected]> |
||
| 15 | */ |
||
| 16 | interface UploadModelInterface |
||
| 17 | { |
||
| 18 | const FILE_TYPE_IMAGE = 'image'; |
||
| 19 | const FILE_TYPE_AUDIO = 'audio'; |
||
| 20 | const FILE_TYPE_VIDEO = 'video'; |
||
| 21 | const FILE_TYPE_APP = 'application'; |
||
| 22 | const FILE_TYPE_APP_WORD = 'word'; |
||
| 23 | const FILE_TYPE_APP_EXCEL = 'excel'; |
||
| 24 | const FILE_TYPE_APP_PDF = 'pdf'; |
||
| 25 | const FILE_TYPE_TEXT = 'text'; |
||
| 26 | const FILE_TYPE_OTHER = 'other'; |
||
| 27 | const FILE_TYPE_THUMB = 'thumbnail'; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Set mediafile model. |
||
| 31 | * |
||
| 32 | * @param Mediafile $model |
||
| 33 | */ |
||
| 34 | public function setMediafileModel(Mediafile $model): void; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Get mediafile model. |
||
| 38 | * |
||
| 39 | * @return Mediafile |
||
| 40 | */ |
||
| 41 | public function getMediafileModel(): Mediafile; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Set file. |
||
| 45 | * |
||
| 46 | * @param UploadedFile|null $file |
||
| 47 | * |
||
| 48 | * @return void |
||
| 49 | */ |
||
| 50 | public function setFile(UploadedFile $file = null): void; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Get file. |
||
| 54 | * |
||
| 55 | * @return mixed |
||
| 56 | */ |
||
| 57 | public function getFile(); |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Save file in storage and database. |
||
| 61 | * |
||
| 62 | * @return bool |
||
| 63 | */ |
||
| 64 | public function save(): bool ; |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Delete file from storage and database. |
||
| 68 | * |
||
| 69 | * @return int |
||
| 70 | */ |
||
| 71 | public function delete(): int; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Returns current model id. |
||
| 75 | * |
||
| 76 | * @return int|string |
||
| 77 | */ |
||
| 78 | public function getId(); |
||
| 79 | |||
| 80 | /** |
||
| 81 | * Create thumbs for this image |
||
| 82 | * |
||
| 83 | * @throws InvalidConfigException |
||
| 84 | * |
||
| 85 | * @return bool |
||
| 86 | */ |
||
| 87 | public function createThumbs(): bool; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * Load data. |
||
| 91 | * Used from the parent model yii\base\Model. |
||
| 92 | * |
||
| 93 | * @param $data |
||
| 94 | * @param null $formName |
||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
| 95 | * |
||
| 96 | * @return bool |
||
| 97 | */ |
||
| 98 | public function load($data, $formName = null); |
||
| 99 | |||
| 100 | /** |
||
| 101 | * Set attributes with their values. |
||
| 102 | * Used from the parent model yii\base\Model. |
||
| 103 | * |
||
| 104 | * @param $values |
||
| 105 | * @param bool $safeOnly |
||
| 106 | * |
||
| 107 | * @return mixed |
||
| 108 | */ |
||
| 109 | public function setAttributes($values, $safeOnly = true); |
||
| 110 | |||
| 111 | /** |
||
| 112 | * Validate data. |
||
| 113 | * Used from the parent model yii\base\Model. |
||
| 114 | * |
||
| 115 | * @param null $attributeNames |
||
|
0 ignored issues
–
show
|
|||
| 116 | * @param bool $clearErrors |
||
| 117 | * |
||
| 118 | * @return mixed |
||
| 119 | */ |
||
| 120 | public function validate($attributeNames = null, $clearErrors = true); |
||
| 121 | |||
| 122 | /** |
||
| 123 | * Returns the errors for all attributes or a single attribute. |
||
| 124 | * Used from the parent model yii\base\Model. |
||
| 125 | * |
||
| 126 | * @param string $attribute attribute name. Use null to retrieve errors for all attributes. |
||
| 127 | * |
||
| 128 | * @return array errors for all attributes or the specified attribute. Empty array is returned if no error. |
||
| 129 | */ |
||
| 130 | public function getErrors($attribute = null); |
||
| 131 | } |
||
| 132 |