1 | <?php |
||
2 | |||
3 | namespace Apps\Controller\Api; |
||
4 | |||
5 | use Apps\ActiveRecord\App as AppRecord; |
||
6 | use Extend\Core\Arch\ApiController; |
||
7 | |||
8 | /** |
||
9 | * Class Content. Content app backend json api |
||
10 | * @package Apps\Controller\Api |
||
11 | */ |
||
12 | class Content extends ApiController |
||
13 | { |
||
14 | public $maxSize = 512000; // in bytes, 500 * 1024 |
||
15 | public $maxResize = 150; |
||
16 | |||
17 | public $allowedExt = ['jpg', 'png', 'gif', 'jpeg', 'bmp', 'webp']; |
||
18 | |||
19 | // import actions from traits |
||
20 | use Content\ActionChangeRate { |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
21 | changeRate as actionChangerate; |
||
22 | } |
||
23 | |||
24 | use Content\ActionGalleryUpload { |
||
25 | galleryUpload as actionGalleryupload; |
||
26 | } |
||
27 | |||
28 | use Content\ActionGalleryList { |
||
0 ignored issues
–
show
|
|||
29 | galleryList as actionGallerylist; |
||
30 | } |
||
31 | |||
32 | use Content\ActionGalleryDelete { |
||
0 ignored issues
–
show
|
|||
33 | galleryDelete as actionGallerydelete; |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * Prepare configurations before initialization |
||
38 | */ |
||
39 | public function before() |
||
40 | { |
||
41 | parent::before(); |
||
42 | $configs = AppRecord::getConfigs('app', 'Content'); |
||
43 | // prevent null-type config data |
||
44 | if ((int)$configs['gallerySize'] > 0) { |
||
45 | $this->maxSize = (int)$configs['gallerySize'] * 1024; |
||
46 | } |
||
47 | |||
48 | if ((int)$configs['galleryResize'] > 0) { |
||
49 | $this->maxResize = (int)$configs['galleryResize']; |
||
50 | } |
||
51 | } |
||
52 | } |
||
53 |