Skip to content

Commit e089592

Browse files
committed
Fixed checks related with getting model in TreeController
1 parent 10ff4a5 commit e089592

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/controllers/TreeController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ protected function getModel($paramName = null, $createIfNotFound = false)
129129
throw new BadRequestHttpException('Model primary key must be specified in order to find model.');
130130
}
131131

132-
if (!$createIfNotFound) {
133-
$model = $modelClass::findOne($pk);
134-
if (!$model) {
132+
$model = $modelClass::findOne($pk);
133+
if (!$model) {
134+
if (!$createIfNotFound) {
135135
throw new NotFoundHttpException('Model not found.');
136+
} else {
137+
$model = new $modelClass;
136138
}
137-
} else {
138-
$model = new $modelClass;
139139
}
140140

141141
if (!($model instanceof ActiveRecord)) {

0 commit comments

Comments
 (0)