/** * Finds the Forum model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Forum the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Forum::findOne(['forum_url' => $id])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Finds the Forum model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Forum the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { $cache = Yii::$app->cache; $cachePrefix = Yii::$app->getModule('forum')->cachePrefix; $cacheKey = $cachePrefix . $id; $model = $cache->get($cacheKey); if ($model === false) { if (($model = Forum::findOne(['forum_url' => $id])) !== null) { $cache->set($cacheKey, $model); return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } } else { return $model; } }