| Total Complexity | 8 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | class DeleteAction extends Action |
||
| 18 | { |
||
| 19 | public $softDeleteAttribute = 'deleted_at'; |
||
| 20 | public $preventAjaxRedirect = false; |
||
| 21 | public $messageOnDelete = 'Model deleted'; |
||
| 22 | |||
| 23 | public function run() |
||
| 24 | { |
||
| 25 | $model = $this->findModel($this->modelClass); |
||
| 26 | $model->delete(); |
||
| 27 | if ($model->hasErrors() || $this->hasSoftDeleteError($model)) { |
||
| 28 | $msg = current($model->getFirstErrors()); |
||
| 29 | Yii::$app->session->setFlash('error', $msg ?: Yii::t('errors', 'Fail Deleting Model')); |
||
|
|
|||
| 30 | } else { |
||
| 31 | Yii::$app->session->setFlash('success', $this->getMessageOnDelete($model)); |
||
| 32 | } |
||
| 33 | |||
| 34 | if (Yii::$app->request->isAjax && !$this->preventAjaxRedirect) { |
||
| 35 | return Yii::$app->response->redirect($this->controller->deleteRedirect($model), 302, false); |
||
| 36 | } |
||
| 37 | |||
| 38 | return $this->controller->redirect($this->controller->deleteRedirect($model)); |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @param ActiveRecord $model |
||
| 43 | * @return bool |
||
| 44 | */ |
||
| 45 | public function hasSoftDeleteError($model): bool |
||
| 51 | } |
||
| 52 | } |
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.