/**
  * @Route("/new/{match_id}")
  * @Template()
  */
 public function newAction($match_id)
 {
     $em = $this->getDoctrine()->getManager();
     $match = $em->find('ClubMatchBundle:Match', $match_id);
     $comment = new \Club\MatchBundle\Entity\MatchComment();
     $comment->setMatch($match);
     $comment->setUser($this->getUser());
     $form = $this->createForm(new \Club\MatchBundle\Form\MatchComment(), $comment);
     if ($this->getRequest()->getMethod() == 'POST') {
         $form->bind($this->getRequest());
         if ($form->isValid()) {
             $em->persist($comment);
             $em->flush();
             $this->get('session')->getFlashBag()->add('notice', $this->get('translator')->trans('Your changes are saved.'));
             return $this->redirect($this->generateUrl('club_match_match_show', array('id' => $match->getId())));
         }
     }
     return array('form' => $form->createView(), 'match' => $match);
 }
示例#2
0
 /**
  * Remove match_comments
  *
  * @param Club\MatchBundle\Entity\MatchComment $matchComments
  */
 public function removeMatchComment(\Club\MatchBundle\Entity\MatchComment $matchComments)
 {
     $this->match_comments->removeElement($matchComments);
 }