Exemplo n.º 1
0
 public function actionIndex($uri = '')
 {
     $page = Page::findOne(['uri' => $uri]);
     if ($page === null) {
         throw new \yii\web\HttpException(404, 'Not found');
     }
     if ($page->status != 1) {
         throw new \yii\web\HttpException(404, 'Not found');
     }
     $this->layout = $page->layout;
     return $this->render('index', ['page' => $page]);
 }
Exemplo n.º 2
0
 /**
  * Finds the Page model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Page the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Page::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }