1 | <?php |
||||
2 | |||||
3 | namespace app\controllers\admin; |
||||
4 | |||||
5 | use Yii; |
||||
6 | use app\traits\{LanguageTrait, AdminBeforeActionTrait, AccessTrait}; |
||||
7 | use app\models\{Feedback, FeedbackSearch}; |
||||
8 | use Itstructure\AdminModule\controllers\CommonAdminController; |
||||
9 | |||||
10 | /** |
||||
11 | * Class FeedbackController |
||||
12 | * FeedbackController implements the CRUD actions for Page model. |
||||
13 | * |
||||
14 | * @package app\controllers\admin |
||||
15 | */ |
||||
16 | class FeedbackController extends CommonAdminController |
||||
17 | { |
||||
18 | use LanguageTrait, AdminBeforeActionTrait, AccessTrait; |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
19 | |||||
20 | /** |
||||
21 | * Set read status to "1" after view record. |
||||
22 | * |
||||
23 | * @param \yii\base\Action $action |
||||
24 | * @param mixed $result |
||||
25 | * |
||||
26 | * @return mixed |
||||
27 | */ |
||||
28 | public function afterAction($action, $result) |
||||
29 | { |
||||
30 | if ($action->id == 'view') { |
||||
31 | $modelId = $action->controller->actionParams['id']; |
||||
32 | Feedback::fixReadStatus((int)$modelId); |
||||
33 | } |
||||
34 | |||||
35 | return parent::afterAction($action, $result); |
||||
36 | } |
||||
37 | |||||
38 | /** |
||||
39 | * @return mixed|string |
||||
40 | */ |
||||
41 | public function actionIndex() |
||||
42 | { |
||||
43 | if (!$this->checkAccessToIndex()) { |
||||
44 | return $this->accessError(); |
||||
45 | } |
||||
46 | |||||
47 | return parent::actionIndex(); |
||||
48 | } |
||||
49 | |||||
50 | /** |
||||
51 | * @param int|string $id |
||||
52 | * |
||||
53 | * @return mixed |
||||
54 | */ |
||||
55 | public function actionView($id) |
||||
56 | { |
||||
57 | if (!$this->checkAccessToView()) { |
||||
58 | return $this->accessError(); |
||||
59 | } |
||||
60 | |||||
61 | return parent::actionView($id); |
||||
62 | } |
||||
63 | |||||
64 | /** |
||||
65 | * @param int|string $id |
||||
66 | * |
||||
67 | * @return mixed|\yii\web\Response |
||||
68 | */ |
||||
69 | public function actionDelete($id) |
||||
70 | { |
||||
71 | if (!$this->checkAccessToDelete()) { |
||||
72 | return $this->accessError(); |
||||
73 | } |
||||
74 | |||||
75 | return parent::actionDelete($id); |
||||
76 | } |
||||
77 | |||||
78 | /** |
||||
79 | * @return mixed|\yii\web\Response |
||||
80 | */ |
||||
81 | public function actionDeleteSelected() |
||||
82 | { |
||||
83 | if (!$this->checkAccessToDelete()) { |
||||
84 | return $this->accessError(); |
||||
85 | } |
||||
86 | |||||
87 | if (Yii::$app->request->isPost) { |
||||
88 | /** @var FeedbackSearch $searchModel */ |
||||
89 | $searchModel = $this->getNewSearchModel(); |
||||
90 | $searchModel->setScenario($searchModel::SCENARIO_DELETE_SELECTED); |
||||
91 | $searchModel->load(Yii::$app->request->post()); |
||||
0 ignored issues
–
show
It seems like
Yii::app->request->post() can also be of type object ; however, parameter $data of yii\base\Model::load() does only seem to accept array , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
92 | $searchModel->deleteSelected(); |
||||
93 | } |
||||
94 | |||||
95 | return $this->redirect([ |
||||
96 | $this->urlPrefix.'index', |
||||
97 | ]); |
||||
98 | } |
||||
99 | |||||
100 | /** |
||||
101 | * Returns Product model name. |
||||
102 | * |
||||
103 | * @return string |
||||
104 | */ |
||||
105 | protected function getModelName():string |
||||
106 | { |
||||
107 | return Feedback::class; |
||||
108 | } |
||||
109 | |||||
110 | /** |
||||
111 | * Returns ProductSearch model name. |
||||
112 | * |
||||
113 | * @return string |
||||
114 | */ |
||||
115 | protected function getSearchModelName():string |
||||
116 | { |
||||
117 | return FeedbackSearch::class; |
||||
118 | } |
||||
119 | } |
||||
120 |