Airship\Cabin\Hull\Blueprint\Blog::getPostsSeries PHP Method

getPostsSeries() public method

Get all of the series' that this post belongs to:
public getPostsSeries ( integer $postId ) : array
$postId integer
return array
    public function getPostsSeries(int $postId) : array
    {
        $series = [];
        foreach ($this->getSeriesForPost($postId) as $ser) {
            if (!empty($ser)) {
                $series[] = $ser;
                $recursion = $this->getSeriesRecursive((int) $ser['seriesid'], [(int) $ser['seriesid']]);
                foreach ($recursion as $par) {
                    if (!empty($par)) {
                        $series[] = $par;
                    }
                }
            }
        }
        foreach ($series as $i => $ser) {
            $series[$i] = $this->getSeriesExtra($ser);
        }
        return $series;
    }

Usage Example

Example #1
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);
     }
 }