/** * @throws \yii\web\NotFoundHttpException * @return string */ public function run() { if ($this->pageId === null) { $this->pageId = Yii::$app->request->get('pageId'); } if (!is_null($this->pageId)) { $model = CmsModel::findOne($this->pageId); if ($model) { $model->content = $this->parseBaseTemplateParams($model->content); if (!empty($this->layout)) { $this->controller->layout = $this->layout; } return $this->controller->render($this->view, ['model' => $model]); } } throw new NotFoundHttpException('The requested page does not exist.'); }
/** * Finds the CmsModel model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * * @param integer $id * * @return CmsModel the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = CmsModel::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException(App::t('yii2mod', 'The requested page does not exist.')); } }
/** * Find CmsModel * * @return null|CmsModel * * @throws NotFoundHttpException */ protected function findModel() { if (($model = CmsModel::findOne($this->pageId)) !== null) { return $model; } throw new NotFoundHttpException(Yii::t('yii2mod.cms', 'The requested page does not exist.')); }