Пример #1
0
 /**
  * @Route("/addComment/{item}" ,name="main_addComment")
  * @Security("has_role('ROLE_USER')")   
  */
 public function addCommentAction(Request $request, Item $item)
 {
     $text = $request->request->get('comment');
     $user = $this->get('security.token_storage')->getToken()->getUser();
     $em = $this->getDoctrine()->getManager();
     $comment = new Comment();
     $comment->setOwner($user);
     $comment->setItem($item);
     $comment->setText($text);
     $em->persist($comment);
     $em->flush();
     return $this->redirect($request->headers->get('referer'));
 }