/** * render a post read * * @param Post $post * @return Response */ private function renderPost(Post $post) { $response = $this->createResponse(); $response->setETag('post_' . $post->getIdentifier()); $response->setLastModified($post->getModified()); //response $request = $this->container->get('request'); if ($response->isNotModified($request)) { return $response; } //only render on not modified return $this->render($this->container->getParameter('madoqua.view.scripts.postread'), array('post' => $post), $response); //render post:read }
/** * 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; }