/** * Reads an article from the given file and returns it. * * @param SplFileInfo $file File to be read. * * @return Article */ public function readFromFile(SplFileInfo $file) { if (!$file->isFile()) { throw new NotFoundException('Could not find requested blog article to read from "' . $file->getPathname() . '".'); } $article = new Article(); $filename = explode('.', $file->getFilename()); $article->setSlug(implode('.', array_slice($filename, 0, -1))); $raw = file_get_contents($file->getPathname()); $article->setRaw($raw); $this->readMarkdown($article, $raw); return $article; }