public function insertkomentarAction(Request $request, $slug)
 {
     $em = $this->getDoctrine()->getManager();
     $posts = $em->getRepository('EntitasBundle:Posts')->findOneBy(array('slug' => $slug));
     if (!$posts) {
         throw $this->createNotFoundException('Unable to find Post entity.');
     }
     $request = $this->getRequest();
     if ($request->getMethod() == 'POST') {
         $isikomen = $request->get('isikomen');
         $komentar = new Komentar();
         $komentar->setCreateAt(new \DateTime('now'));
         $komentar->setUpdateAt(new \DateTime('now'));
         $komentar->setPengkomen($this->getUser());
         $komentar->setIsikomen($isikomen);
         $komentar->setPostingan($posts);
         $em->persist($komentar);
         $em->flush();
         #return $this->redirect($this->generateUrl('blog_show', array('slug' => $slug)));
     }
     $komentar = $em->createQuery("SELECT u,p,k FROM EntitasBundle:Komentar k \n                                                JOIN k.postingan p\n                                                JOIN k.pengkomen u WHERE (p.slug=:slug)");
     $komentar->setParameter('slug', $slug);
     $komentar = $komentar->getScalarResult();
     $jlhkomentar = count($komentar);
     $template = $this->renderView('BlogBundle:Post:ajaxkomentar.html.twig', array('komentar' => $komentar, 'jlhkomentar' => $jlhkomentar));
     return new JsonResponse(array('message' => $template), 200);
 }
 /**
  * Displays a form to create a new Komentar entity.
  *
  */
 public function newAction()
 {
     $entity = new Komentar();
     $entity->setCreateAt(new \DateTime('now'));
     $entity->setUpdateAt(new \DateTime('now'));
     $entity->setPengkomen($this->getUser());
     $form = $this->createCreateForm($entity);
     return $this->render('EntitasBundle:Komentar:new.html.twig', array('entity' => $entity, 'form' => $form->createView()));
 }