Skip to content

Commit 5f1000f

Browse files
author
Igor Chepurnoy
authored
Update FindModelTrait.php
1 parent 9d86eec commit 5f1000f

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

traits/FindModelTrait.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,22 @@
1212
*/
1313
trait FindModelTrait
1414
{
15-
/**
16-
* @var string message for the NotFoundHttpException
17-
*/
18-
protected $notFoundMessage = 'The requested page does not exist.';
19-
2015
/**
2116
* Finds model
2217
*
2318
* @param $modelClass ActiveRecord
2419
* @param mixed $condition primary key value or a set of column values
20+
* @param string $notFoundMessage
2521
* @return ActiveRecord
22+
*
2623
* @throws NotFoundHttpException
2724
*/
28-
protected function findModel($modelClass, $condition)
25+
protected function findModel($modelClass, $condition, $notFoundMessage = 'The requested page does not exist.')
2926
{
3027
if (($model = $modelClass::findOne($condition)) !== null) {
3128
return $model;
3229
} else {
33-
throw new NotFoundHttpException($this->notFoundMessage);
30+
throw new NotFoundHttpException($notFoundMessage);
3431
}
3532
}
36-
}
33+
}

0 commit comments

Comments
 (0)