Passed
Push — master ( dd4450...9a9614 )
by Andrey
05:55
created

CategoryController::getSearchModelName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace app\controllers\admin;
4
5
use app\models\{Category, CategorySearch};
6
use app\traits\{LanguageTrait, AdminBeforeActionTrait, AccessTrait};
7
use Itstructure\AdminModule\controllers\CommonAdminController;
8
9
/**
10
 * Class CategoryController
11
 * CategoryController implements the CRUD actions for Page model.
12
 *
13
 * @package app\controllers\admin
14
 */
15
class CategoryController extends CommonAdminController
16
{
17
    use LanguageTrait, AdminBeforeActionTrait, AccessTrait;
0 ignored issues
show
Bug introduced by
The trait app\traits\LanguageTrait requires the property $request which is not provided by app\controllers\admin\CategoryController.
Loading history...
introduced by
The trait app\traits\AdminBeforeActionTrait requires some properties which are not provided by app\controllers\admin\CategoryController: $request, $controller
Loading history...
Bug introduced by
The trait app\traits\AccessTrait requires the property $user which is not provided by app\controllers\admin\CategoryController.
Loading history...
18
19
    /**
20
     * @var bool
21
     */
22
    protected $isMultilanguage = true;
23
24
    /**
25
     * @var bool
26
     */
27
    protected $setEditingScenarios = true;
28
29
    /**
30
     * @return mixed|string
31
     */
32
    public function actionIndex()
33
    {
34
        if (!$this->checkAccessToIndex()) {
35
            return $this->accessError();
36
        }
37
38
        return parent::actionIndex();
39
    }
40
41
    /**
42
     * @param int|string $id
43
     *
44
     * @return mixed
45
     */
46
    public function actionView($id)
47
    {
48
        if (!$this->checkAccessToView()) {
49
            return $this->accessError();
50
        }
51
52
        return parent::actionView($id);
53
    }
54
55
    /**
56
     * @return mixed|string|\yii\web\Response
57
     */
58
    public function actionCreate()
59
    {
60
        if (!$this->checkAccessToCreate()) {
61
            return $this->accessError();
62
        }
63
64
        $this->additionFields['categories'] = Category::getMenu();
65
66
        return parent::actionCreate();
67
    }
68
69
    /**
70
     * @param int|string $id
71
     *
72
     * @return string|\yii\web\Response
73
     */
74
    public function actionUpdate($id)
75
    {
76
        if (!$this->checkAccessToUpdate()) {
77
            return $this->accessError();
78
        }
79
80
        $this->additionFields['categories'] = Category::getMenu();
81
82
        return parent::actionUpdate($id);
83
    }
84
85
    /**
86
     * @param int|string $id
87
     *
88
     * @return mixed|\yii\web\Response
89
     */
90
    public function actionDelete($id)
91
    {
92
        if (!$this->checkAccessToDelete()) {
93
            return $this->accessError();
94
        }
95
96
        return parent::actionDelete($id);
97
    }
98
99
    /**
100
     * Returns Category model name.
101
     *
102
     * @return string
103
     */
104
    protected function getModelName():string
105
    {
106
        return Category::class;
107
    }
108
109
    /**
110
     * Returns CategorySearch model name.
111
     *
112
     * @return string
113
     */
114
    protected function getSearchModelName():string
115
    {
116
        return CategorySearch::class;
117
    }
118
}
119