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.

ReviewModule::behaviors()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace app\modules\review;
4
5
use app\components\BaseModule;
6
use app\models\BaseObject;
7
use app\modules\event\interfaces\EventInterface;
8
use app\modules\floatPanel\widgets\FloatingPanel;
9
use app\modules\page\models\Page;
10
use app\modules\review\models\Review;
11
use app\modules\shop\models\Category;
12
use app\modules\shop\models\Product;
13
use kartik\icons\Icon;
14
use yii\base\Event;
15
16
/**
17
 * Base configuration module for DotPlant2 CMS
18
 * @package app\modules\review
19
 */
20
class ReviewModule extends BaseModule implements EventInterface
21
{
22
    /**
23
     * @var int Max reviews on page
24
     */
25
    public $maxPerPage = 10;
26
27
    /**
28
     * @var int Default number of reviews on page
29
     */
30
    public $pageSize = 10;
31
32
    /**
33
     * @var bool Enable spam checking
34
     */
35
    public $enableSpamChecking = false;
36
37
    /**
38
     * @return array the behavior configurations.
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use array<string,array<string,string>>.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
39
     */
40
    public function behaviors()
41
    {
42
        return [
43
            'configurableModule' => [
44
                'class' => 'app\modules\config\behaviors\ConfigurableModuleBehavior',
45
                'configurationView' => '@app/modules/review/views/configurable/_config',
46
                'configurableModel' => 'app\modules\review\models\ConfigConfigurationModel',
47
            ]
48
        ];
49
    }
50
51
    /**
52
     * @return void
53
     */
54
    public static function attachEventsHandlers()
55
    {
56
        Event::on(
57
            FloatingPanel::class,
58
            FloatingPanel::EVENT_BEFORE_RENDER,
59
            function ($event) {
60
                $objectId = 0;
61
                $modelId = 0;
62
63
                switch (\Yii::$app->requestedRoute) {
64
                    case "shop/product/show":
65
                        $product = \Yii::$container->get(Product::class);
66
                        $objectId = BaseObject::getForClass(get_class($product))->id;
67
                        $modelId = $_GET['model_id'];
68
                        break;
69
70
                    case "shop/product/list":
71
                        $objectId = BaseObject::getForClass(Category::class)->id;
72
                        $modelId = $_GET['last_category_id'];
73
                        break;
74
75
                    case "/page/page/show":
76
                    case "/page/page/list":
77
                        $objectId = BaseObject::getForClass(Page::class)->id;
78
                        $modelId = $_GET['id'];
79
                        break;
80
                }
81
                $reviews = Review::getForObjectModel($modelId, $objectId, 1);
82
                if (!empty($reviews)) {
83
                    $event->items[] = [
84
                        "label" => Icon::show("pencil") . \Yii::t("app", "Edit reviews") . " (" . count($reviews) . ")",
85
                        "url" => [
86
                            "/review/backend-review/index",
87
                            "SearchModel" => [
88
                                "object_id" => $objectId,
89
                                "object_model_id" => $modelId
90
                            ]
91
                        ],
92
                        "target" => "_blank"
93
                    ];
94
                }
95
            }
96
        );
97
    }
98
}
99