getCommentTree() public method

Get all of the blog comments for a given blog post
public getCommentTree ( integer $blogPostId ) : array
$blogPostId integer
return array
示例#1
0
 /**
  * @param CacheInterface $cache
  * @param string $uniqueID
  */
 protected function fetchComments(CacheInterface $cache, string $uniqueID)
 {
     $blog = $this->blog->getBlogPostByUniqueId($uniqueID);
     $comments = $this->blog->getCommentTree((int) $blog['postid']);
     $contents = $this->lensRender('blog/comments', ['blogpost' => $blog, 'comments' => $comments, 'config' => $this->config()]);
     $cache->set($uniqueID, ['status' => 'OK', 'cached' => $contents]);
     \Airship\json_response(['status' => 'OK', 'cached' => $contents]);
 }
示例#2
0
 /**
  * Read a blog post
  *
  * @param string $year
  * @param string $month
  * @param string $slug
  *
  * @route blog/{year}/{month}/{slug}
  */
 public function readPost(string $year, string $month, string $slug)
 {
     $blogPost = $this->blog->getBlogPost($year, $month, $slug);
     $post = $this->post(new CommentFilter(), true);
     if ($post) {
         if ($this->addComment($post, (int) $blogPost['postid'])) {
             \Airship\redirect(\Airship\LensFunctions\cabin_url() . 'blog/' . $year . '/' . $month . '/' . $slug . '#comments');
         }
     }
     $mathJAX = \strpos($blogPost['body'], '$$') !== false;
     $blogPost['series'] = $this->blog->getPostsSeries((int) $blogPost['postid']);
     $args = ['meta' => \json_decode($blogPost['metadata'] ?? '[]', true), 'pageTitle' => $blogPost['title'], 'blogpost' => $blogPost, 'author' => $this->blog->getAuthor($blogPost['author']), 'config' => $this->config(), 'mathjax' => $mathJAX];
     if (!empty($blogPost['cache'])) {
         $args['cached'] = true;
         $this->stasis('blog/read', $args);
     } else {
         $comments = $this->blog->getCommentTree((int) $blogPost['postid']);
         $args['comments'] = $comments;
         $this->lens('blog/read', $args);
     }
 }