/**
  * @param Request $request
  *
  * @throws \LogicException
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function createAction(Request $request)
 {
     if (true !== $request->isXmlHttpRequest()) {
         throw new \LogicException('The request should be an Xml Http request.');
     }
     $comment = $this->commentBuilder->buildCommentWithoutSubject($this->getUser());
     $createForm = $this->formFactory->create('pim_comment_comment', $comment);
     $createForm->submit($request);
     if (true !== $createForm->isValid()) {
         return new JsonResponse('The form is not valid.', 400);
     }
     $this->commentManager->save($comment);
     $reply = $this->commentBuilder->buildReply($comment, $this->getUser());
     $replyForm = $this->formFactory->create('pim_comment_comment', $reply, ['is_reply' => true]);
     return $this->templating->renderResponse('PimCommentBundle:Comment:_thread.html.twig', ['replyForms' => [$comment->getId() => $replyForm->createView()], 'comment' => $comment]);
 }