setPath() public method

Set the item's relative path.
public setPath ( string $value, $snapshotName )
$value string e.g: "index.html" or "my-page/index.html"
$snapshotName The name of the snapshot. The snapshot "last" is not valid
コード例 #1
0
ファイル: ContentManager.php プロジェクト: jjk-jacky/Spress
 private function convertItem(ItemInterface $item)
 {
     $this->eventDispatcher->dispatch('spress.before_convert', new Event\ContentEvent($item, ItemInterface::SNAPSHOT_RAW, ItemInterface::SNAPSHOT_PATH_RELATIVE));
     $path = $item->getPath(ItemInterface::SNAPSHOT_PATH_RELATIVE);
     $ext = pathinfo($path, PATHINFO_EXTENSION);
     $result = $this->converterManager->convertContent($item->getContent(), $ext);
     $newPath = preg_replace('/\\.' . $ext . '$/', '.' . $result->getExtension(), $path);
     $item->setContent($result->getResult(), ItemInterface::SNAPSHOT_AFTER_CONVERT);
     $item->setPath($newPath, ItemInterface::SNAPSHOT_PATH_RELATIVE);
     $this->eventDispatcher->dispatch('spress.after_convert', new Event\ContentEvent($item, ItemInterface::SNAPSHOT_AFTER_CONVERT, ItemInterface::SNAPSHOT_PATH_RELATIVE));
     $this->siteAttribute->setItem($item);
 }
コード例 #2
0
ファイル: ContentManager.php プロジェクト: spress/spress-core
 private function convertItem(ItemInterface $item)
 {
     $path = $item->getPath(ItemInterface::SNAPSHOT_PATH_RELATIVE);
     if ($item->isBinary() === true) {
         $item->setPath($path, ItemInterface::SNAPSHOT_PATH_RELATIVE_AFTER_CONVERT);
         return;
     }
     $this->eventDispatcher->dispatch('spress.before_convert', new Event\ContentEvent($item, ItemInterface::SNAPSHOT_RAW, ItemInterface::SNAPSHOT_PATH_RELATIVE));
     $result = $this->converterManager->convertItem($item);
     $str = new StringWrapper($path);
     $filenameWithoutExtension = $str->deleteSufix($result->getInputExtension());
     $newPath = $filenameWithoutExtension . $result->getExtension();
     $item->setContent($result->getResult(), ItemInterface::SNAPSHOT_AFTER_CONVERT);
     $item->setPath($newPath, ItemInterface::SNAPSHOT_PATH_RELATIVE_AFTER_CONVERT);
     $this->eventDispatcher->dispatch('spress.after_convert', new Event\ContentEvent($item, ItemInterface::SNAPSHOT_AFTER_CONVERT, ItemInterface::SNAPSHOT_PATH_RELATIVE_AFTER_CONVERT));
 }