public function newCommentAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$post = $em->getRepository('AppBundle:Post')->find($id);
$comment = new Comment();
$comment->setPost($post);
$form = $this->createForm(new CommentRestType(), $comment);
$form->submit($request);
if ($form->isValid()) {
$em->persist($comment);
$em->flush();
return $this->routeRedirectView('api_v1_get_comment', array('id' => $comment->getId()));
}
$view = $this->view($form)->setTemplate('RestBundle:Comment:newComment.html.twig');
return $this->handleView($view);
}