Esempio n. 1
0
 /**
  * create file from SplFileInfo
  *
  * @param SplFileInfo $file 
  * @return Post
  */
 private function createFileFromFileInfo(\SplFileInfo $file)
 {
     $post = new Post($this->getFilter());
     $post->setText(file_get_contents((string) $file));
     $post->setIdentifier(str_replace('.markdown', '', $file->getFilename()));
     $post->setCreated($file->getCTime());
     $post->setModified($file->getMTime());
     $matches = array();
     $found = preg_match('/#.*/', $post->getText(), $matches);
     if ($found === false) {
         $title = $file->getFilename();
     } else {
         $title = ltrim(array_shift($matches), '#');
     }
     $post->setTitle($title);
     //parse title out of body text
     return $post;
 }