BackendFilter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A beforeAction() 0 8 2
1
<?php
2
3
/*
4
 * This file is part of the Dektrium project
5
 *
6
 * (c) Dektrium project <http://github.com/dektrium>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
11
12
namespace backend\filters;
13
14
use yii\web\NotFoundHttpException;
15
use yii\base\ActionFilter;
16
17
/**
18
 * BackendFilter is used to allow access only to admin and security controller in frontend when using Yii2-user with
19
 * Yii2 advanced template.
20
 *
21
 * @author Dmitry Erofeev <[email protected]>
22
 */
23
class BackendFilter extends ActionFilter
24
{
25
    /**
26
     * @var array
27
     */
28
    public $controllers = ['recovery'];
29
30
    /**
31
     * @param \yii\base\Action $action
32
     *
33
     * @return bool
34
     * @throws \yii\web\NotFoundHttpException
35
     */
36
    public function beforeAction($action)
37
    {
38
        if (in_array($action->controller->id, $this->controllers)) {
39
            throw new NotFoundHttpException('Not found');
40
        }
41
42
        return true;
43
    }
44
}
45