SiteController::actionLogout()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace app\controllers;
4
5
use Yii;
6
use yii\filters\AccessControl;
7
use yii\web\Controller;
8
use yii\filters\VerbFilter;
9
10
class SiteController extends Controller
11
{
12
    /**
13
     * @inheritdoc
14
     */
15
    public function behaviors()
16
    {
17
        return [
18
            'access' => [
19
                'class' => AccessControl::className(),
20
                'only' => ['logout'],
21
                'rules' => [
22
                    [
23
                        'actions' => ['logout'],
24
                        'allow' => true,
25
                        'roles' => ['@'],
26
                    ],
27
                ],
28
            ],
29
            'verbs' => [
30
                'class' => VerbFilter::className(),
31
                'actions' => [
32
                    'logout' => ['post'],
33
                ],
34
            ],
35
        ];
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41
    public function actions()
42
    {
43
        return [
44
            'error' => [
45
                'class' => 'yii\web\ErrorAction',
46
            ],
47
            'captcha' => [
48
                'class' => 'yii\captcha\CaptchaAction',
49
                'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
50
            ],
51
        ];
52
    }
53
54
    /**
55
     * Displays homepage.
56
     *
57
     * @return string
58
     */
59
    public function actionIndex()
60
    {
61
        return $this->render('index');
62
    }
63
64
    /**
65
     * Logout action.
66
     *
67
     * @return string
68
     */
69
    public function actionLogout()
70
    {
71
        Yii::$app->user->logout();
72
73
        return $this->goHome();
74
    }
75
}
76