GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Setup Failed
Push — filters ( 4ff9c7...c25ab7 )
by Alexander
10:29 queued 01:15
created

BackendModule   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 8
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 83
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A backendGridLabels() 0 9 1
B bootstrap() 0 25 5
A behaviors() 0 10 1
A isBackend() 0 4 1
1
<?php
2
3
namespace app\backend;
4
5
use app\backend\components\BackendController;
6
use app\backend\widgets\FloatingPanel;
7
use Yii;
8
use yii\base\BootstrapInterface;
9
use yii\base\Module;
10
use yii\web\Application;
11
use yii\web\View;
12
13
/**
14
 * Base DotPlant2 Backend module handling core backend functions and floating panel
15
 * @package app\backend
16
 */
17
class BackendModule extends Module implements BootstrapInterface
18
{
19
    const BACKEND_GRID_ONE_TO_ONE = 'one_to_one';
20
    const BACKEND_GRID_ONE_COLUMN = 'one_column';
21
    const BACKEND_GRID_ONE_TO_TWO = 'one_to_two';
22
    const BACKEND_GRID_TWO_TO_ONE = 'two_to_one';
23
24
    public $administratePermission = 'administrate';
25
26
    public $defaultRoute = 'dashboard/index';
27
28
    /**
29
     * @var array Configuration array for floating panel for content-managers
30
     */
31
    public $floatingPanel = [];
32
33
    public $wysiwygUploadDir = '/upload/images';
34
35
    public $backendEditGrids = [];
36
37
    public static function backendGridLabels()
38
    {
39
        return [
40
            self::BACKEND_GRID_ONE_COLUMN => Yii::t('app', 'One column'),
41
            self::BACKEND_GRID_ONE_TO_ONE => Yii::t('app', 'One to one'),
42
            self::BACKEND_GRID_ONE_TO_TWO => Yii::t('app', 'One to two'),
43
            self::BACKEND_GRID_TWO_TO_ONE => Yii::t('app', 'Two to one'),
44
        ];
45
    }
46
47
    /**
48
     * @inheritdoc
49
     */
50
    public function bootstrap($app)
51
    {
52
        $app->on(
53
            Application::EVENT_BEFORE_ACTION,
54
            function () use ($app) {
55
                if (
56
                    Yii::$app->request->isAjax === false &&
57
                    Yii::$app->requestedAction->controller->module instanceof BackendModule === false &&
58
                    Yii::$app->requestedAction->controller instanceof BackendController === false
59
                ) {
60
                    if (Yii::$app->user->can('administrate')) {
61
                        /*
62
                         * Apply floating panel only if requested action is not a part of backend
63
                         */
64
                        $app->getView()->on(
65
                            View::EVENT_BEGIN_BODY,
66
                            function () {
67
                                echo FloatingPanel::widget($this->floatingPanel);
68
                            }
69
                        );
70
                    }
71
                }
72
            }
73
        );
74
    }
75
76
    /**
77
     * @inheritdoc
78
     */
79
    public function behaviors()
80
    {
81
        return [
82
            'configurableModule' => [
83
                'class' => 'app\modules\config\behaviors\ConfigurableModuleBehavior',
84
                'configurationView' => '@app/backend/views/configurable/_config',
85
                'configurableModel' => 'app\backend\models\ConfigConfigurationModel',
86
            ]
87
        ];
88
    }
89
90
    /**
91
     * Check if current request is being served by backend
92
     *
93
     * @return bool true - backend, false - frontend
94
     */
95
    public static function isBackend()
96
    {
97
        return Yii::$app->controller instanceof BackendController === true;
98
    }
99
}
100