Пример #1
0
 /**
  * Searches the index for a matching post.
  * If found, it creates a new Post object with filtered content
  * 
  * @return mixed  found Post or null
  */
 public function findById($id, $expand = true)
 {
     $index = $this->getPostIndex();
     $postMeta = $index->get($id);
     if ($postMeta) {
         $postMeta = (object) $postMeta;
         if ($expand === false) {
             # return unexpanded post
             return $postMeta;
         }
         $fileinfo = new \SplFileInfo($postMeta->filepath);
         $parser = new Parser($this->readFile($fileinfo));
         $post = new Post($postMeta);
         $post->setRawContent($parser->getContent());
         if (!is_null($this->contentFilter)) {
             $post->setContentFilter($this->contentFilter);
         }
         list($prev, $next) = $this->findPrevAndNextPosts($id);
         $post->prev = $prev;
         $post->next = $next;
         return $post;
     }
 }