예제 #1
0
파일: blog.php 프로젝트: NeroJz/ci_doctrine
 public function comments()
 {
     $id = $this->uri->segment(3);
     $post = $this->em->getRepository('Entities\\Post')->find($id);
     if ($post === NULL) {
         throw new \Exception("Post not found!");
     }
     $add = $this->input->post('comment');
     if ($add == 'comment') {
         $body = $this->input->post('post-comment');
         $comment = new Comment();
         $comment->setBody($body);
         $comment->setPublicationDate(new \DateTime());
         $comment->setPost($post);
         $this->em->persist($comment);
         $this->em->flush();
         redirect('blog/comments/' . $post->getId(), 'refresh');
     }
     $data['content'] = $this->load->view('blog\\comments', array('post' => $post), true);
     $this->load->view('main', $data);
 }
예제 #2
0
파일: Post.php 프로젝트: NeroJz/ci_doctrine
 /**
  * Add comment
  *
  * @param \Entities\Comment $comment
  *
  * @return Post
  */
 public function addComment(\Entities\Comment $comment)
 {
     $this->comments[] = $comment;
     $comment->setPost($this);
     return $this;
 }