/**
  * Creates a new Comment entity for the video.
  *
  */
 public function videoCommentCreateAction($slug)
 {
     $translator = $this->get('translator');
     $em = $this->getDoctrine()->getManager();
     // get video
     $video = $em->getRepository('VideoBundle:Video')->findOneBy(array('slug' => $slug));
     if (!$video) {
         throw $this->createNotFoundException($translator->trans('AdministrationBundle.notFound', array("%name%" => "video")));
         //'Unable to find Type entity.');
     }
     // get user
     $user = $this->getUser();
     // get lang
     $lang = $this->get('request')->get('lang');
     if (!$lang) {
         $lang = "en";
     }
     // get comment
     $comment = $this->get('request')->get('comment');
     // add comment
     if ($comment) {
         $entity = new Comment();
         $entity->setVideo($video);
         $entity->setUser($user);
         $entity->setLang($lang);
         $entity->setComment($comment);
         $em->persist($entity);
         $em->flush();
     }
     // get all comments
     $comments = $em->getRepository('EventBundle:Comment')->getCommentsByVideo($video, $lang);
     $templating = $this->get('templating');
     $reponse = $templating->render('EventBundle:Congres:comments.html.twig', array('comments' => $comments));
     // return Response
     return new Response($reponse);
 }
 /**
  * Comment List
  *
  * @param String $slug
  * @return Response     
  *
  */
 public function commentListAction($slug)
 {
     $translator = $this->get('translator');
     $em = $this->getDoctrine()->getManager();
     // get article
     $article = $em->getRepository('NewsBundle:Article')->findOneBy(array('slug' => $slug));
     //findBySlug($slug);
     if (!$article) {
         throw $this->createNotFoundException($translator->trans('AdministrationBundle.notFound', array("%name%" => "article")));
         //'Unable to find Type entity.');
     }
     // get lang
     $lang = $this->get('request')->getLocale();
     if (!$lang) {
         $lang = "en";
     }
     // get user
     $user = $this->getUser();
     // get comment
     $comment = $this->get('request')->get('text');
     // add comment
     if ($comment) {
         $entity = new Comment();
         $entity->setArticle($article);
         $entity->setUser($user);
         $entity->setLang($lang);
         $entity->setComment($comment);
         $em->persist($entity);
         $em->flush();
     }
     // get all comments
     $comments = $em->getRepository('EventBundle:Comment')->getCommentsByArticle($article, $lang);
     $reponse = array();
     foreach ($comments as $key => $comment) {
         # code...
         $reponse[$key]['author'] = $comment->getUser()->getFirstname() . " " . $comment->getUser()->getLastname();
         $reponse[$key]['text'] = $comment->getComment();
         if ($lang == "en") {
             $reponse[$key]['date'] = $comment->getCommentDate()->format('Y-m-d H:i');
         } else {
             $reponse[$key]['date'] = $comment->getCommentDate()->format('d/m/Y H:i');
         }
     }
     return new JsonResponse($reponse);
 }