コード例 #1
0
ファイル: CommentManager.php プロジェクト: xphere/elcodi
 /**
  * Edit a comment
  *
  * @param CommentInterface $comment Comment
  * @param string           $content Content
  *
  * @return CommentInterface Edited comment
  */
 public function editComment(CommentInterface $comment, $content)
 {
     $comment->setContent($content);
     $this->commentDirector->save($comment);
     $this->commentEventDispatcher->dispatchCommentOnEditEvent($comment);
     return $this;
 }
コード例 #2
0
ファイル: CommentCache.php プロジェクト: raizeta/elcodi
 /**
  * Create structure for comment
  *
  * @param CommentInterface $comment            Comment
  * @param VotePackage      $commentVotePackage Vote package
  *
  * @return array
  */
 public function createCommentStructure(CommentInterface $comment, VotePackage $commentVotePackage = null)
 {
     $commentStructure = ['id' => $comment->getId(), 'authorName' => $comment->getAuthorName(), 'authorEmail' => $comment->getAuthorEmail(), 'content' => $comment->getContent(), 'context' => $comment->getContext(), 'createdAt' => $comment->getCreatedAt()->format('Y-m-d H:i:s'), 'updatedAt' => $comment->getUpdatedAt()->format('Y-m-d H:i:s')];
     if ($commentVotePackage instanceof VotePackage) {
         $commentStructure = array_merge($commentStructure, ['nbVotes' => $commentVotePackage->getNbVotes(), 'nbUpVotes' => $commentVotePackage->getNbUpVotes(), 'nbDownVotes' => $commentVotePackage->getNbDownVotes()]);
     }
     return $commentStructure;
 }