/**
  * Processes a new comment
  *
  * @param Request  $request
  * @param Response $response
  * @param array    $args
  *
  * @return Response
  */
 public function createComment(Request $request, Response $response, array $args)
 {
     $validator = $this->createCommentValidator();
     $rawData = $request->request->all();
     $result = $validator->run($rawData);
     if ($result->isValid()) {
         $comment = new Comment($rawData['comment'], isset($rawData['internal']) ? true : false);
         $comment->setAuthor($request->attributes->get('stack.authn.caller'));
         $entity = $this->em->getRepository($this->entityClass)->find($args['id']);
         $entity->addComment($comment);
         $this->em->flush();
     }
     return new RedirectResponse(sprintf('%s/%s', $this->route, $args['id']));
 }
 /**
  * Adds a comment
  *
  * @param Comment $comment
  */
 public function addComment(Comment $comment)
 {
     $comment->setService($this);
     $this->comments->add($comment);
 }