getFile() public method

public getFile ( )
Esempio n. 1
0
 public function processDocumentDecoration(Document $document)
 {
     $event = new CarewEvent(array($document));
     try {
         return $this->eventDispatcher->dispatch(Events::DOCUMENT_DECORATION, $event)->getSubject();
     } catch (\Exception $e) {
         if ($document->getFile()) {
             throw new \LogicException(sprintf('Could not process "%s": "%s".', $document->getFile()->getRelativePathname(), $e->getMessage()), 0, $e);
         }
         throw new \LogicException(sprintf('Could not process "%s": "%s".', $document->getBody(), $e->getMessage()), 0, $e);
     }
 }
Esempio n. 2
0
 private function onPost(Document $document)
 {
     list($year, $month, $day, $slug) = explode('-', $document->getFile()->getBasename('.md'), 4);
     $document->addMetadatas(array('date' => new \DateTime("{$year}-{$month}-{$day}")));
     $metadatas = $document->getMetadatas();
     if (!isset($metadatas['permalink'])) {
         $path = strtr($this->permalinkFormat, array('%year%' => $year, '%month%' => $month, '%day%' => $day, '%slug%' => $slug));
         $document->setPath($this->path->generatePath($path));
     }
 }