/**
  * @Route("/comment/{slug}/create", name="ed_blog_admin_comment_create")
  * @ParamConverter("article", class="ED\BlogBundle\Interfaces\Model\ArticleInterface", converter="abstract_converter")
  */
 public function createAction(Request $request, $article)
 {
     $user = $this->getUser();
     $blogSettings = $this->get('blog_settings');
     if ($this->container->get('security.authorization_checker')->isGranted('ACCESS_COMMENTS', $user) === false || $this->container->get('security.authorization_checker')->isGranted('CREATE_COMMENT', $user) === false) {
         throw new AccessDeniedHttpException("Sorry, commenting is currently disabled by blog administrator.");
     }
     $object = $this->get('comment_generator')->getObject();
     $object->setAuthor($user)->setArticle($article);
     $class = get_class($object);
     $form = $this->createForm('edcomment', $object);
     if ($request->isMethod('POST')) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $em = $this->getDoctrine()->getManager();
             if ($user && $user->hasRole('ROLE_BLOG_ADMIN')) {
                 $object->setStatus(Comment::STATUS_ACTIVE);
             } else {
                 $object->setStatus($blogSettings->manualCommentsApprove() ? Comment::STATUS_PENDING : Comment::STATUS_ACTIVE);
             }
             $em->persist($object);
             $em->flush();
             $dispatcher = $this->get("event_dispatcher");
             $dispatcher->dispatch(EDBlogEvents::ED_BLOG_COMMENT_CREATED, new CommentEvent($object));
             $resetObject = new $class();
             $resetObject->setAuthor($user)->setArticle($article);
             $form = $this->createForm('edcomment', $resetObject);
         }
     }
     $comments = $this->getDoctrine()->getRepository($class)->findByArticle($article, $this->get("blog_settings")->getCommentsDisplayOrder());
     return new JsonResponse(array('success' => true, 'lock' => true, 'currentComment' => IDEncrypt::encrypt($object->getId()), 'html' => $this->renderView("@EDBlog/Comment/list.html.twig", array('form' => $form->createView(), 'article' => $article, 'comments' => $comments))));
 }
 public function encrypt($id)
 {
     $return = IDEncrypt::encrypt($id);
     return $return;
 }