/** * Finds the CommentModel model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return CommentModel the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = CommentModel::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Find model by ID. * * @param integer|array $id Model ID * * @return CommentModel Model * * @throws HttpException 404 error if model not found */ protected function findModel($id) { if (is_array($id)) { /** @var CommentModel $model */ $model = CommentModel::findAll($id); } else { /** @var CommentModel $model */ $model = CommentModel::findOne($id); } if ($model !== null) { return $model; } else { throw new HttpException(404); } }