コード例 #1
0
ファイル: CommentManagerTest.php プロジェクト: xphere/elcodi
 /**
  * Test loading simple comments from source
  */
 public function testAddComment()
 {
     /**
      * @var CommentInterface $comment
      */
     $comment = $this->commentManager->addComment('source', 'context', 'This is my content', '12345', 'Marc Morera', '*****@*****.**', null);
     $this->assertEquals('source', $comment->getSource());
     $this->assertGreaterThan(0, $comment->getId());
     $this->assertEquals('This is my content', $comment->getContent());
 }
コード例 #2
0
 /**
  * Add a comment.
  *
  * @param Request $request     Request
  * @param string  $authorToken Author Token
  * @param string  $context     Context
  * @param string  $source      Source
  *
  * @return Response
  */
 public function addCommentAction(Request $request, $authorToken, $context, $source)
 {
     $requestBag = $request->request;
     $content = $requestBag->get('content');
     $authorName = $requestBag->get('author_name');
     $authorEmail = $requestBag->get('author_email');
     $parentId = $requestBag->get('parent');
     /**
      * @var CommentInterface|null $parent
      */
     $parent = $parentId > 0 ? $this->commentRepository->find($parentId) : null;
     $comment = $this->commentManager->addComment($source, $context, $content, $authorToken, $authorName, $authorEmail, $parent);
     $commentStructure = $this->commentCache->createCommentStructure($comment);
     return new Response(json_encode(['entity' => $commentStructure, 'children' => []]));
 }