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.
Passed
Push — master ( 0d3847...631d1f )
by Alexander
06:12
created

PageModule   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A behaviors() 0 10 1
A getBackendGrids() 0 10 1
B attachEventsHandlers() 0 31 4
1
<?php
2
3
namespace app\modules\page;
4
5
use app;
6
use app\modules\event\interfaces\EventInterface;
7
use app\modules\floatPanel\widgets\FloatingPanel;
8
use kartik\icons\Icon;
9
use Yii;
10
use yii\base\Event;
11
12
/**
13
 * Base configuration module for DotPlant2 CMS
14
 * @package app\modules\page
15
 */
16
class PageModule extends app\components\BaseModule implements EventInterface
17
{
18
    const BACKEND_PAGE_GRID = 'pageGrid';
19
    /**
20
     * @var int minimum pages per list to show
21
     */
22
    public $minPagesPerList = 1;
23
24
    /**
25
     * @var int maximum pages per list to show
26
     */
27
    public $maxPagesPerList = 50;
28
29
    /**
30
     * @var int pages per list to show
31
     */
32
    public $pagesPerList = 10;
33
34
    /**
35
     * @var int How much pages to show on search results page
36
     */
37
    public $searchResultsLimit = 10;
38
39
    public $controllerMap = [
40
        'backend' => 'app\modules\page\backend\PageController',
41
    ];
42
43
    /**
44
     * @inheritdoc
45
     */
46
    public function behaviors()
47
    {
48
        return [
49
            'configurableModule' => [
50
                'class' => 'app\modules\config\behaviors\ConfigurableModuleBehavior',
51
                'configurationView' => '@app/modules/page/views/configurable/_config',
52
                'configurableModel' => 'app\modules\page\models\ConfigConfigurationModel',
53
            ]
54
        ];
55
    }
56
57
    /** @inheritdoc */
58
    public function getBackendGrids()
59
    {
60
        return [
61
            [
62
                'defaultValue' => app\backend\BackendModule::BACKEND_GRID_ONE_TO_ONE,
63
                'key' => self::BACKEND_PAGE_GRID,
64
                'label' => Yii::t('app', 'Page edit'),
65
            ],
66
        ];
67
    }
68
69
    /**
70
     * @return void
71
     */
72
    public static function attachEventsHandlers()
0 ignored issues
show
Coding Style introduced by
attachEventsHandlers uses the super-global variable $_GET which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
73
    {
74
        Event::on(
75
            FloatingPanel::class,
76
            FloatingPanel::EVENT_BEFORE_RENDER,
77
            function($event) {
78
                if (in_array(\Yii::$app->requestedRoute, ['/page/page/show', '/page/page/list'])) {
79
                    if (isset($_GET['id'])) {
80
                        $page = app\modules\page\models\Page::findById($_GET['id']);
81
                        $event->items[] = [
82
                            'label' => Icon::show('pencil') . ' ' . Yii::t('app', 'Edit page'),
83
                            'url' => [
84
                                '/page/backend/edit',
85
                                'id' => $page->id,
86
                                'parent_id' =>$page->parent_id,
87
                            ],
88
                        ];
89
                        if (Yii::$app->requestedRoute == "/page/page/list") {
90
                            $event->items[] = [
91
                                'label' => Icon::show('plus') .  Yii::t('app', 'Add child page'),
92
                                'url' => [
93
                                    '/page/backend/edit',
94
                                    'parent_id' => $page->id
95
                                ]
96
                            ];
97
                        }
98
                    }
99
                }
100
            }
101
        );
102
    }
103
}
104