FilesController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 27
dl 0
loc 62
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A behaviors() 0 14 1
A actions() 0 43 1
1
<?php
2
/**
3
 * Date: 12.07.16
4
 * Time: 14:47
5
 */
6
7
namespace execut\import\controllers;
8
9
use execut\actions\action\adapter\Edit;
10
use execut\actions\action\adapter\EditWithRelations;
11
use execut\crud\params\Crud;
12
13
use execut\import\models\File;
14
use execut\actions\Action;
15
use execut\actions\action\adapter\File as FileAdapter;
16
use yii\filters\AccessControl;
17
use yii\helpers\ArrayHelper;
18
use yii\web\Controller;
19
20
class FilesController extends Controller
21
{
22
    public function behaviors()
23
    {
24
        return array_merge([
25
            'access' => [
26
                'class' => AccessControl::class,
27
                'rules' => [
28
                    [
29
                        'allow' => true,
30
                        'roles' => \yii::$app->getModule('import')->getAllowedRoles(),
31
                    ],
32
                ],
33
            ],
34
        ],
35
            parent::behaviors()
36
        );
37
    }
38
39
    public function actions()
40
    {
41
        $crud = new Crud([
42
            'modelClass' => File::class,
43
            'module' => 'import',
44
            'moduleName' => 'Import',
45
            'modelName' => File::MODEL_NAME,
46
        ]);
47
        ini_set('max_execution_time', 0);
48
        return ArrayHelper::merge($crud->actions(), [
49
            'update' => [
50
                'adapter' => [
51
                    'class' => Edit::class,
52
                    'filesAttributes' => [
53
                        'content' => 'contentFile'
54
                    ],
55
//                    'relationAdapterConfig' => [
56
//                        'importLogsFormGroupedByCategory' => [
57
//                            'view' => [
58
//                                'refreshAttributes' => [
59
//                                    'id',
60
//                                ],
61
//                                'isAllowedAdding' => false,
62
//                            ],
63
//                        ],
64
//                        'importLogsForm' => [
65
//                            'view' => [
66
//                                'refreshAttributes' => [
67
//                                    'id',
68
//                                ],
69
//                                'isAllowedAdding' => false,
70
//                            ],
71
//                        ],
72
//                    ],
73
                ],
74
            ],
75
            'download' => [
76
                'class' => Action::class,
77
                'adapter' => [
78
                    'class' => FileAdapter::class,
79
                    'modelClass' => File::class,
80
                    'extensionIsRequired' => false,
81
                    'dataAttribute' => 'content',
82
                ],
83
            ],
84
        ]);
85
    }
86
}