public function newAction($blogId) { $blog = $this->getBlog($blogId); $comment = new Comment(); $comment->setPostid($blog); $form = $this->createForm(new CommentType(), $comment); return $this->render('AppBlogBundle:Comment:form.html.twig', array('comment' => $comment, 'form' => $form->createView())); }
public function addComment($blogId, $commentText, $role) { $blog = $this->em->getRepository('AppBlogBundle:Blog')->findBlogById($blogId); $comment = new Comment(); $comment->setPostid($blog); $comment->setText($commentText); $comment->setCreatedon(new \DateTime()); $comment->setupdatedon(new \DateTime()); $comment->setAuthor($this->em->getRepository('AppBlogBundle:User')->find($role)); $comment->setIsactive(1); $this->em->persist($comment); $this->em->flush(); return $comment->getId(); }