|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* HiPanel core package |
|
5
|
|
|
* |
|
6
|
|
|
* @link https://hipanel.com/ |
|
7
|
|
|
* @package hipanel-core |
|
8
|
|
|
* @license BSD-3-Clause |
|
9
|
|
|
* @copyright Copyright (c) 2014-2016, HiQDev (http://hiqdev.com/) |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace hipanel\controllers; |
|
13
|
|
|
|
|
14
|
|
|
use hipanel\actions\ProxyAction; |
|
15
|
|
|
use hipanel\actions\RedirectAction; |
|
16
|
|
|
use hipanel\actions\RenderAction; |
|
17
|
|
|
use Yii; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* HiPanel controller. |
|
21
|
|
|
* Just redirects to dashboard. |
|
22
|
|
|
*/ |
|
23
|
|
|
class HipanelController extends \hipanel\base\Controller |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* {@inheritdoc} |
|
27
|
|
|
*/ |
|
28
|
|
View Code Duplication |
public function behaviors() |
|
|
|
|
|
|
29
|
|
|
{ |
|
30
|
|
|
return [ |
|
31
|
|
|
'access' => [ |
|
32
|
|
|
'class' => 'yii\filters\AccessControl', |
|
33
|
|
|
'only' => ['index'], |
|
34
|
|
|
'rules' => [ |
|
35
|
|
|
[ |
|
36
|
|
|
'actions' => ['index'], |
|
37
|
|
|
'allow' => true, |
|
38
|
|
|
'roles' => ['@'], |
|
39
|
|
|
], |
|
40
|
|
|
], |
|
41
|
|
|
], |
|
42
|
|
|
]; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* {@inheritdoc} |
|
47
|
|
|
*/ |
|
48
|
|
|
public function actions() |
|
49
|
|
|
{ |
|
50
|
|
|
return [ |
|
51
|
|
|
'index' => [ |
|
52
|
|
|
'class' => RedirectAction::class, |
|
53
|
|
|
'url' => ['/dashboard/dashboard'], |
|
54
|
|
|
], |
|
55
|
|
|
/// later just for testing |
|
56
|
|
|
'switch' => [ |
|
57
|
|
|
'class' => RenderAction::class, |
|
58
|
|
|
'addFlash' => true, |
|
59
|
|
|
'success' => Yii::t('app', 'DB truncate task has been created successfully'), |
|
60
|
|
|
'error' => Yii::t('app', 'Error while truncating DB'), |
|
61
|
|
|
'POST html' => [ |
|
62
|
|
|
'class' => ProxyAction::class, |
|
63
|
|
|
'action' => 'index', |
|
64
|
|
|
], |
|
65
|
|
|
'GET' => [ |
|
66
|
|
|
'class' => RenderAction::class, |
|
67
|
|
|
'view' => 'index', |
|
68
|
|
|
], |
|
69
|
|
|
'POST pjax' => [ |
|
70
|
|
|
'class' => RenderAction::class, |
|
71
|
|
|
'view' => 'index', |
|
72
|
|
|
], |
|
73
|
|
|
'default' => [ |
|
74
|
|
|
'class' => RedirectAction::class, |
|
75
|
|
|
'url' => ['index'], |
|
76
|
|
|
], |
|
77
|
|
|
], |
|
78
|
|
|
'proxy' => [ |
|
79
|
|
|
'class' => ProxyAction::class, |
|
80
|
|
|
'action' => 'index', |
|
81
|
|
|
], |
|
82
|
|
|
'render' => [ |
|
83
|
|
|
'class' => RenderAction::class, |
|
84
|
|
|
'view' => 'index', |
|
85
|
|
|
], |
|
86
|
|
|
'redirect' => [ |
|
87
|
|
|
'class' => RedirectAction::class, |
|
88
|
|
|
'url' => ['index'], |
|
89
|
|
|
], |
|
90
|
|
|
]; |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.