Completed
Pull Request — master (#8)
by
unknown
03:42
created

VhostController::behaviors()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 11
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
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
                    '*' => 'account.read',
36
                ],
37
            ],
38
        ]);
39
    }
40
41
    public function actions()
42
    {
43
        return array_merge(parent::actions(), [
44
            'index' => [
45
                'class' => RedirectAction::class,
46
                'url' => ['@hdomain/index'],
47
            ],
48
            'search' => [
49
                'class' => ComboSearchAction::class,
50
            ],
51
            'view' => [
52
                'class' => RedirectAction::class,
53
                'url' => ArrayHelper::merge(['@hdomain/view'], Yii::$app->request->get()),
54
            ],
55
            'advanced-config' => [
56
                'class' => SmartUpdateAction::class,
57
                'findOptions' => [
58
                    'select' => 'advanced',
59
                ],
60
                'success' => Yii::t('hipanel:hosting', 'Advanced settings were updated successfully'),
61
                'error'   => Yii::t('hipanel:hosting', 'Error when updating advanced settings'),
62
            ],
63
            'manage-proxy' => [
64
                'class' => SmartUpdateAction::class,
65
                'findOptions' => [
66
                    'select' => 'advanced',
67
                    'with_backends' => true,
68
                ],
69
                'success' => Yii::t('hipanel:hosting', 'Domain proxy setting settings were changed'),
70
                'error' => Yii::t('hipanel:hosting', 'Error when changing domain proxy settings'),
71
            ],
72
            'validate-form' => [
73
                'class' => ValidateFormAction::class,
74
            ],
75
        ]);
76
    }
77
}
78