- public function getPageComments($pageId) {
- $comments = $this->comment->getAllPageComments($pageId);
- $index = [];
- $totalComments = count($comments);
- $finalCommentList = [];
-
- // normalizing the response.
- for ($i = 0; $i < count($comments); ++$i) {
- $comment = $this->normalizeComment($comments[$i]);
- $parentId = $comment->parent_id;
- if (empty($parentId)) {
- $finalCommentList[] = $comment;
- $index[$comment->id] = $comment;
- continue;
- }
-
- if (empty($index[$parentId])) {
- // weird condition should not happen.
- continue;
- }
- if (empty($index[$parentId]->sub_comments)) {
- $index[$parentId]->sub_comments = [];
- }
- array_push($index[$parentId]->sub_comments, $comment);
- $index[$comment->id] = $comment;
- }
- return [
- 'comments' => $finalCommentList,
- 'total' => $totalComments
- ];
- }
-
- public function getCommentById($commentId) {
- return $this->normalizeComment($this->comment->getCommentById($commentId));
+ /**
+ * Delete a comment from the system.
+ * @param Comment $comment
+ * @return mixed
+ */
+ public function delete($comment)
+ {
+ return $comment->delete();