/**
  * {@inheritDoc}
  */
 public function getCommentaires()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCommentaires', array());
     return parent::getCommentaires();
 }
Example #2
0
 public function ajouterCommentaireAction(Article $article)
 {
     // plus besoin de recup lentite grace a ParamConverter
     // il transforme $id en une instance de article contenu dans $article
     $listeArticleCompetence = $this->getCustomRepository('SerialkenBlogBundle:ArticleCompetence')->findbyArticle($article->getid());
     $listeCommentaires = $article->getCommentaires();
     $commentaire = new Commentaire();
     $commentaire->setAuteur($this->getUser());
     $form = $this->createForm(new CommentaireType(), $commentaire);
     //$form = $this->createForm(new CommentaireType, $article->getCommentaires());
     if ($this->get('request')->getMethod() == 'POST') {
         //pour le moment on fait rien
         $form->bind($this->get('request'));
         if ($form->isValid()) {
             $article->addCommentaire($commentaire);
             $this->getDoctrine()->getManager()->flush();
             //$this->get('session')->getFlashBag()->add('info', 'Article bien modifié');
             //et apres je redirige vers la page pour visualiser le larticle modifier
             return $this->redirect($this->generateUrl('serialkenblog_voir', array('id' => $article->getId())));
         }
     }
     return $this->render('SerialkenBlogBundle:Blog:voir.html.twig', array('article' => $article, 'comment' => true, 'listeArticleCompetence' => $listeArticleCompetence, 'listeCommentaires' => $listeCommentaires, 'form' => $form->createView()));
 }