| Conditions | 4 |
| Paths | 6 |
| Total Lines | 22 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 25 | public function run() |
||
| 26 | { |
||
| 27 | if ($this->checkAccess) { |
||
| 28 | call_user_func($this->checkAccess, $this->id); |
||
| 29 | } |
||
| 30 | |||
| 31 | /* @var $model \yii\db\ActiveRecord */ |
||
| 32 | $model = new $this->modelClass([ |
||
| 33 | 'scenario' => $this->scenario, |
||
| 34 | ]); |
||
| 35 | |||
| 36 | $model->load(Yii::$app->getRequest()->getBodyParams(), ''); |
||
| 37 | if ($model->save()) { |
||
| 38 | $response = Yii::$app->getResponse(); |
||
| 39 | $response->setStatusCode(200); |
||
| 40 | $id = implode(',', array_values($model->getPrimaryKey(true))); |
||
| 41 | return $model->findOne($id); |
||
| 42 | } elseif (!$model->hasErrors()) { |
||
| 43 | throw new ServerErrorHttpException('Failed to create the object for unknown reason.'); |
||
| 44 | } |
||
| 45 | |||
| 46 | return $model; |
||
| 47 | } |
||
| 49 |