]> BookStack Code Mirror - bookstack/blobdiff - app/Exports/ZipExports/ZipExportBuilder.php
ZIP Exports: Added core logic for books/chapters
[bookstack] / app / Exports / ZipExports / ZipExportBuilder.php
index 15edebea574fb344f3440e3e6cb6951fdab51b03..42fb03541c014a3c5a38ea18aaf05d3b63fddc6b 100644 (file)
@@ -2,8 +2,12 @@
 
 namespace BookStack\Exports\ZipExports;
 
+use BookStack\Entities\Models\Book;
+use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Page;
 use BookStack\Exceptions\ZipExportException;
+use BookStack\Exports\ZipExports\Models\ZipExportBook;
+use BookStack\Exports\ZipExports\Models\ZipExportChapter;
 use BookStack\Exports\ZipExports\Models\ZipExportPage;
 use ZipArchive;
 
@@ -30,6 +34,32 @@ class ZipExportBuilder
         return $this->build();
     }
 
+    /**
+     * @throws ZipExportException
+     */
+    public function buildForChapter(Chapter $chapter): string
+    {
+        $exportChapter = ZipExportChapter::fromModel($chapter, $this->files);
+        $this->data['chapter'] = $exportChapter;
+
+        $this->references->addChapter($exportChapter);
+
+        return $this->build();
+    }
+
+    /**
+     * @throws ZipExportException
+     */
+    public function buildForBook(Book $book): string
+    {
+        $exportBook = ZipExportBook::fromModel($book, $this->files);
+        $this->data['book'] = $exportBook;
+
+        $this->references->addBook($exportBook);
+
+        return $this->build();
+    }
+
     /**
      * @throws ZipExportException
      */