1 | <?php |
||
2 | |||
3 | |||
4 | namespace carono\yii2crud\actions; |
||
5 | |||
6 | |||
7 | use carono\yii2crud\CrudController; |
||
8 | use Yii; |
||
9 | use yii\db\ActiveRecord; |
||
10 | use yii\helpers\Html; |
||
11 | |||
12 | /** |
||
13 | * Class CreateAction |
||
14 | * |
||
15 | * @package carono\yii2crud\actions |
||
16 | * @property CrudController $controller |
||
17 | * @method getMessageOnCreate(\yii\db\ActiveRecord $model) |
||
18 | */ |
||
19 | class CreateAction extends Action |
||
20 | { |
||
21 | public $view = 'create'; |
||
22 | public $loadDefaultValues = true; |
||
23 | public $loadGetParams = true; |
||
24 | public $skipIfSet = true; |
||
25 | public $messageOnCreate = 'Model Successful Created'; |
||
26 | |||
27 | public function run() |
||
28 | { |
||
29 | /** |
||
30 | * @var ActiveRecord $class |
||
31 | * @var ActiveRecord $model |
||
32 | */ |
||
33 | $class = $this->modelClass ?: ($this->controller->createClass ?: $this->controller->modelClass); |
||
34 | $model = new $class(); |
||
35 | $this->controller->beforeCreate($model); |
||
36 | if ($this->loadDefaultValues) { |
||
37 | $model->loadDefaultValues($this->skipIfSet); |
||
38 | } |
||
39 | if ($this->loadGetParams) { |
||
40 | $model->load(\Yii::$app->request->get()); |
||
41 | } |
||
42 | if ($model->load(Yii::$app->request->post())) { |
||
43 | if ($model->save()) { |
||
44 | Yii::$app->session->setFlash('success', $this->getMessageOnCreate($model)); |
||
0 ignored issues
–
show
|
|||
45 | return $this->controller->redirect($this->controller->createRedirect($model)); |
||
46 | } |
||
47 | Yii::$app->session->setFlash('error', Html::errorSummary($model)); |
||
48 | } |
||
49 | return $this->controller->render($this->view, ['model' => $model]); |
||
50 | } |
||
51 | } |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.