Completed
Push — master ( ccdb45...342210 )
by Dmitry
12s queued 10s
created

VhostController::behaviors()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 12
ccs 0
cts 12
cp 0
rs 9.4285
c 2
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Hosting Plugin for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-hosting
6
 * @package   hipanel-module-hosting
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
/**
12
 * @see    http://hiqdev.com/hipanel-module-hosting
13
 * @license http://hiqdev.com/hipanel-module-hosting/license
14
 * @copyright Copyright (c) 2015 HiQDev
15
 */
16
17
namespace hipanel\modules\hosting\controllers;
18
19
use hipanel\actions\ComboSearchAction;
20
use hipanel\actions\RedirectAction;
21
use hipanel\actions\SmartUpdateAction;
22
use hipanel\actions\ValidateFormAction;
23
use hipanel\helpers\ArrayHelper;
24
use hipanel\filters\EasyAccessControl;
25
use Yii;
26
27
class VhostController extends \hipanel\base\CrudController
28
{
29
    public function behaviors()
30
    {
31
        return array_merge(parent::behaviors(), [
32
            [
33
                'class' => EasyAccessControl::class,
34
                'actions' => [
35
                    'advanced-config,manage-proxy' => 'account.update',
36
                    '*' => 'account.read',
37
                ],
38
            ],
39
        ]);
40
    }
41
42
    public function actions()
43
    {
44
        return array_merge(parent::actions(), [
45
            'index' => [
46
                'class' => RedirectAction::class,
47
                'url' => ['@hdomain/index'],
48
            ],
49
            'search' => [
50
                'class' => ComboSearchAction::class,
51
            ],
52
            'view' => [
53
                'class' => RedirectAction::class,
54
                'url' => ArrayHelper::merge(['@hdomain/view'], Yii::$app->request->get()),
55
            ],
56
            'advanced-config' => [
57
                'class' => SmartUpdateAction::class,
58
                'findOptions' => [
59
                    'select' => 'advanced',
60
                ],
61
                'success' => Yii::t('hipanel:hosting', 'Advanced settings were updated successfully'),
62
                'error'   => Yii::t('hipanel:hosting', 'Error when updating advanced settings'),
63
            ],
64
            'manage-proxy' => [
65
                'class' => SmartUpdateAction::class,
66
                'findOptions' => [
67
                    'select' => 'advanced',
68
                    'with_backends' => true,
69
                ],
70
                'success' => Yii::t('hipanel:hosting', 'Domain proxy setting settings were changed'),
71
                'error' => Yii::t('hipanel:hosting', 'Error when changing domain proxy settings'),
72
            ],
73
            'validate-form' => [
74
                'class' => ValidateFormAction::class,
75
            ],
76
        ]);
77
    }
78
}
79