1 | <?php |
||
14 | class UsersController extends \yii\web\Controller |
||
15 | { |
||
16 | use ModelTrait; |
||
17 | |||
18 | 33 | public function behaviors() |
|
19 | { |
||
20 | return [ |
||
21 | 'verbs' => [ |
||
22 | 'class' => VerbFilter::class, |
||
23 | 'actions' => [ |
||
24 | 'set-active' => ['post'], |
||
25 | 'set-block' => ['post'], |
||
26 | 'delete' => ['post'], |
||
27 | 'operations' => ['post'], |
||
28 | 'photo-upload' => ['post'], |
||
29 | 'autocomplete' => ['post'], |
||
30 | ], |
||
31 | 33 | ], |
|
32 | ]; |
||
33 | } |
||
34 | |||
35 | 33 | public function actions() |
|
36 | { |
||
37 | return [ |
||
38 | 'operations' => [ |
||
39 | 'class' => 'app\modules\admin\controllers\common\OperationsAction', |
||
40 | 'modelClass' => 'app\models\User', |
||
41 | 'operations' => [ |
||
42 | 'delete' => [], |
||
43 | 'set-active' => ['status' => User::STATUS_ACTIVE], |
||
44 | 'set-block' => ['status' => User::STATUS_BLOCKED] |
||
45 | ] |
||
46 | 33 | ], |
|
47 | 'set-active' => [ |
||
48 | 'class' => 'app\modules\admin\controllers\common\UpdateAttributesAction', |
||
49 | 'modelClass' => 'app\models\User', |
||
50 | 'attributes' => ['status' => User::STATUS_ACTIVE], |
||
51 | ], |
||
52 | 'set-block' => [ |
||
53 | 'class' => 'app\modules\admin\controllers\common\UpdateAttributesAction', |
||
54 | 'modelClass' => 'app\models\User', |
||
55 | 'attributes' => ['status' => User::STATUS_BLOCKED], |
||
56 | ], |
||
57 | 'delete' => [ |
||
58 | 'class' => 'app\modules\admin\controllers\common\DeleteAction', |
||
59 | 'modelClass' => 'app\models\User', |
||
60 | ], |
||
61 | 'photo-upload' => [ |
||
62 | 'class' => 'rkit\filemanager\actions\UploadAction', |
||
63 | 'modelClass' => 'app\models\UserProfile', |
||
64 | 'attribute' => 'photo', |
||
65 | 'inputName' => 'file', |
||
66 | ], |
||
67 | ]; |
||
68 | } |
||
69 | |||
70 | 33 | public function actionIndex() |
|
83 | |||
84 | 10 | public function actionEdit($id = null) |
|
85 | { |
||
86 | 10 | $model = new User(); |
|
87 | |||
88 | 10 | if ($id) { |
|
89 | 6 | $model = $this->findModel($model, $id); |
|
|
|||
90 | } |
||
91 | |||
92 | 10 | if (Yii::$app->request->isPost) { |
|
93 | 6 | if ($model->isNewRecord) { |
|
94 | 4 | $model->setConfirmed(); |
|
95 | } |
||
96 | |||
97 | 6 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
|
98 | 4 | $this->assignRole($model); |
|
99 | |||
100 | 4 | Yii::$app->session->setFlash('success', Yii::t('app.messages', 'Saved successfully')); |
|
101 | 4 | $urlToModel = Url::toRoute(['edit', 'id' => $model->id]); |
|
102 | 4 | if (Yii::$app->request->isAjax) { |
|
103 | 1 | return $this->asJson(['redirect' => $urlToModel]); |
|
104 | } |
||
105 | 3 | return $this->redirect($urlToModel); |
|
106 | } |
||
107 | 2 | if (Yii::$app->request->isAjax) { |
|
108 | 1 | return $this->asJson($this->collectErrors($model)); |
|
109 | } |
||
110 | } |
||
111 | |||
112 | 9 | return $this->render('edit', [ |
|
113 | 9 | 'model' => $model, |
|
114 | 9 | 'roles' => Yii::$app->authManager->getRoles() |
|
115 | ]); |
||
116 | } |
||
117 | |||
118 | 5 | public function actionProfile($id) |
|
140 | |||
141 | 1 | public function actionAutocomplete() |
|
142 | { |
||
143 | 1 | $result = []; |
|
161 | |||
162 | 4 | private function assignRole($model) |
|
174 | } |
||
175 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: