X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/a6633642232efd164d4708967ab59e498fbff896..refs/pull/3387/head:/app/Actions/CommentRepo.php diff --git a/app/Actions/CommentRepo.php b/app/Actions/CommentRepo.php index 13a83e7fd..2f2dd658a 100644 --- a/app/Actions/CommentRepo.php +++ b/app/Actions/CommentRepo.php @@ -1,21 +1,21 @@ -comment = $comment; @@ -45,7 +45,8 @@ class CommentRepo $comment->parent_id = $parent_id; $entity->comments()->save($comment); - ActivityService::addForEntity($entity, ActivityType::COMMENTED_ON); + ActivityService::add(ActivityType::COMMENTED_ON, $entity); + return $comment; } @@ -58,25 +59,26 @@ class CommentRepo $comment->text = $text; $comment->html = $this->commentToHtml($text); $comment->save(); + return $comment; } /** * Delete a comment from the system. */ - public function delete(Comment $comment) + public function delete(Comment $comment): void { $comment->delete(); } /** - * Convert the given comment markdown text to HTML. + * Convert the given comment Markdown to HTML. */ public function commentToHtml(string $commentText): string { $converter = new CommonMarkConverter([ - 'html_input' => 'strip', - 'max_nesting_level' => 10, + 'html_input' => 'strip', + 'max_nesting_level' => 10, 'allow_unsafe_links' => false, ]); @@ -88,7 +90,9 @@ class CommentRepo */ protected function getNextLocalId(Entity $entity): int { - $comments = $entity->comments(false)->orderBy('local_id', 'desc')->first(); - return ($comments->local_id ?? 0) + 1; + /** @var Comment $comment */ + $comment = $entity->comments(false)->orderBy('local_id', 'desc')->first(); + + return ($comment->local_id ?? 0) + 1; } }