1 | <?php |
||
29 | abstract class CommonAdminController extends AdminController |
||
30 | { |
||
31 | /** |
||
32 | * Watch or not created record. |
||
33 | * |
||
34 | * @var bool |
||
35 | */ |
||
36 | protected $viewCreated = false; |
||
37 | |||
38 | /** |
||
39 | * Addition fields for the view template. |
||
40 | * |
||
41 | * @var array |
||
42 | */ |
||
43 | protected $additionFields = []; |
||
44 | |||
45 | /** |
||
46 | * Addition attributes with values for the model. |
||
47 | * [ |
||
48 | * 'key1' => 'value1', |
||
49 | * 'key2' => 'value2', |
||
50 | * ] |
||
51 | * @var array |
||
52 | */ |
||
53 | protected $additionAttributes = []; |
||
54 | |||
55 | /** |
||
56 | * Installing the multilingual mode. |
||
57 | * |
||
58 | * @var bool |
||
59 | */ |
||
60 | protected $isMultilanguage = false; |
||
61 | |||
62 | /** |
||
63 | * If it is true, scenarios 'create' and 'update' will be set automatically for app model extending from ActiveRecord. |
||
64 | * |
||
65 | * @var bool |
||
66 | */ |
||
67 | protected $setEditingScenarios = false; |
||
68 | |||
69 | /** |
||
70 | * Model object record. |
||
71 | * |
||
72 | * @var ModelInterface |
||
73 | */ |
||
74 | private $model; |
||
75 | |||
76 | /** |
||
77 | * Search new model object. |
||
78 | * |
||
79 | * @var BaseActiveRecord |
||
80 | */ |
||
81 | private $searchModel; |
||
82 | |||
83 | /** |
||
84 | * Validate component. |
||
85 | * |
||
86 | * @var ValidateComponentInterface |
||
87 | */ |
||
88 | private $validateComponent; |
||
89 | |||
90 | /** |
||
91 | * Returns the name of the base model. |
||
92 | * |
||
93 | * @return string |
||
94 | */ |
||
95 | abstract protected function getModelName():string; |
||
96 | |||
97 | /** |
||
98 | * Returns the name of the model to search it. |
||
99 | * |
||
100 | * @return string |
||
101 | */ |
||
102 | abstract protected function getSearchModelName():string; |
||
103 | |||
104 | /** |
||
105 | * Initialize. |
||
106 | * |
||
107 | * @throws InvalidConfigException |
||
108 | * |
||
109 | * @return void |
||
110 | */ |
||
111 | public function init() |
||
125 | |||
126 | /** |
||
127 | * Set model. |
||
128 | * |
||
129 | * @param $model ModelInterface |
||
130 | */ |
||
131 | public function setModel(ModelInterface $model): void |
||
135 | |||
136 | /** |
||
137 | * Set search model. |
||
138 | * |
||
139 | * @param $model BaseActiveRecord |
||
140 | */ |
||
141 | public function setSearchModel(BaseActiveRecord $model): void |
||
145 | |||
146 | /** |
||
147 | * Set validate component for main model. |
||
148 | * |
||
149 | * @param $component ValidateComponentInterface |
||
150 | */ |
||
151 | public function setValidateComponent(ValidateComponentInterface $component): void |
||
155 | |||
156 | /** |
||
157 | * Returns model. |
||
158 | * |
||
159 | * @return ModelInterface |
||
160 | */ |
||
161 | public function getModel(): ModelInterface |
||
165 | |||
166 | /** |
||
167 | * Returns search model. |
||
168 | * |
||
169 | * @return BaseActiveRecord |
||
170 | */ |
||
171 | public function getSearchModel(): BaseActiveRecord |
||
175 | |||
176 | /** |
||
177 | * Get validate component for main model. |
||
178 | * |
||
179 | * @return ValidateComponentInterface |
||
180 | */ |
||
181 | public function getValidateComponent(): ValidateComponentInterface |
||
185 | |||
186 | /** |
||
187 | * List of records. |
||
188 | * |
||
189 | * @return string |
||
190 | */ |
||
191 | public function actionIndex() |
||
207 | |||
208 | /** |
||
209 | * Displays one model entry. |
||
210 | * |
||
211 | * @param int|string $id |
||
212 | * |
||
213 | * @return mixed |
||
214 | */ |
||
215 | public function actionView($id) |
||
226 | |||
227 | /** |
||
228 | * Creates a new model record. |
||
229 | * If the result of creation is successful, there will be a redirect to the 'view' or 'index' page. |
||
230 | * |
||
231 | * @return string|\yii\web\Response |
||
232 | */ |
||
233 | public function actionCreate() |
||
265 | |||
266 | /** |
||
267 | * Updates the current model entry. |
||
268 | * If the result of creation is successful, there will be a redirect to the 'view' or 'index' page. |
||
269 | * |
||
270 | * @param int|string $id |
||
271 | * |
||
272 | * @return string|\yii\web\Response |
||
273 | */ |
||
274 | public function actionUpdate($id) |
||
298 | |||
299 | /** |
||
300 | * Deletes the current model entry. |
||
301 | * If the result of the deletion is successful, there will be a redirect to the 'index' page. |
||
302 | * |
||
303 | * @param int|string $id |
||
304 | * |
||
305 | * @return \yii\web\Response |
||
306 | * |
||
307 | * @throws ConflictHttpException |
||
308 | */ |
||
309 | public function actionDelete($id) |
||
321 | |||
322 | /** |
||
323 | * Set addition attributes for model. |
||
324 | * |
||
325 | * @return bool |
||
326 | */ |
||
327 | protected function setAdditionAttributes(): bool |
||
333 | |||
334 | /** |
||
335 | * Get addition fields for the view template. |
||
336 | * |
||
337 | * @return array |
||
338 | */ |
||
339 | protected function getAdditionFields(): array |
||
343 | |||
344 | /** |
||
345 | * Returns new object of main model. |
||
346 | * |
||
347 | * @return mixed |
||
348 | */ |
||
349 | protected function getNewModel() |
||
354 | |||
355 | /** |
||
356 | * Returns new object of search main model. |
||
357 | * |
||
358 | * @return mixed |
||
359 | */ |
||
360 | protected function getNewSearchModel() |
||
365 | |||
366 | /** |
||
367 | * Find model record. |
||
368 | * If the model is not found, a 404 HTTP exception will be displayed. |
||
369 | * |
||
370 | * @param int|string $key |
||
371 | * |
||
372 | * @throws BadRequestHttpException |
||
373 | * @throws UnknownMethodException |
||
374 | * @throws NotFoundHttpException |
||
375 | * |
||
376 | * @return mixed |
||
377 | */ |
||
378 | protected function findModel($key) |
||
403 | |||
404 | /** |
||
405 | * Returns an intermediate model for working with the main. |
||
406 | * |
||
407 | * @param int|string|null $key |
||
408 | * |
||
409 | * @return void |
||
410 | */ |
||
411 | private function setModelByConditions($key = null): void |
||
428 | } |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..