Esempio n. 1
0
 public function run()
 {
     $model = Fragment::findOne(['short_code' => $this->short_code]);
     if ($model) {
         return $this->render('side-fragment', ['title' => $model->title, 'model' => $model]);
     }
 }
Esempio n. 2
0
 /**
  * Finds the Fragment model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Fragment the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Fragment::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }