예제 #1
0
 /**
  * @param $id
  *
  * @return Post
  * @throws HttpException
  */
 public function getPost($id)
 {
     $post = Post::instance()->findByPk((int) $id);
     if ($post == null) {
         throw new HttpException(404, "Post not found");
     }
     return $post;
 }
예제 #2
0
 public function actionShow($id)
 {
     $post = Post::instance()->findByPk((int) $id);
     if ($post && isset($post->title)) {
         $this->view->titlePage = "Блог - " . $post->title;
     } else {
         throw new HttpException(404, "Not found page.");
     }
     if (Request::isAjax()) {
         echo $this->view->render("show", ['post' => $post], false, false);
         exit;
     }
     $this->view->render("show", ['post' => $post]);
 }