Пример #1
0
 public function indexAction()
 {
     $posts = Post::find('all');
     $out_posts = array();
     foreach ($posts as $post) {
         $user = User::findById($post->users_id);
         $post->name = $user->name ? $user->name : 'NoNaMe person';
         $out_posts[] = $post;
     }
     return $this->render('index.html', array('posts' => $out_posts));
 }
Пример #2
0
 /**
  * Get Action
  *
  * @return \Framework\Response\Response
  */
 public function getAction()
 {
     $user = User::findById(Service::get('session')->get('authenticated')->id);
     return $this->render('profile.html', array('user' => $user));
 }
Пример #3
0
 /**
  * Show user all posts
  *
  * @param $id
  * @return \Framework\Response\ResponseRedirect
  * @throws HttpNotFoundException
  */
 public function showUserPostsAction($id)
 {
     if ($posts = Post::findByUsers_id((int) $id, 50)) {
         $user = User::findById((int) $id);
         $name = $user->name ? $user->name : 'NoNaMe person';
         foreach ($posts as $post) {
             $post->name = $name;
         }
         return $this->render('index.html', array('posts' => $posts));
     } else {
         throw new HttpNotFoundException('Page Not Found!');
     }
 }