Guest User

Untitled

a guest
Feb 18th, 2015
24
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace apps\frontend\controllers;
  2.  
  3. use framerock\core\Controller;
  4. use apps\frontend\models\Post;
  5.  
  6. class PostController extends Controller
  7. {
  8.    public function list()
  9.    {
  10.         $data = Post::findAll();
  11.         // template engine
  12.         return $this->template->view('/path/to/list.tpl', $data);
  13.    }
  14.  
  15.    public function content($id)
  16.    {
  17.         $data = Post::findOne($id);
  18.         return $this->template->view('/path/to/content.tpl', $data);
  19.    }
  20.  
  21.    public static function create($title, $content)
  22.    {
  23.         $post = new Post;
  24.         $post->title = $title;
  25.         $post->content = $content;
  26.         return $post->save();
  27.    }
  28. }
RAW Paste Data