Skip to content

Commit 3d6fd0c

Browse files
author
Kallef Alexandre
committed
allow download after zip
1 parent c443cd5 commit 3d6fd0c

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/Epub.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,21 +163,22 @@ protected function generateMimeType(): void
163163
* @param string $path
164164
* @return void
165165
*/
166-
public function saveRaw(string $path): void
166+
public function saveRaw(string $path): string
167167
{
168168
$this->generateEpub();
169-
FileManager::getInstance()->copyAllTo($path);
169+
return FileManager::getInstance()->copyAllTo($path);
170170
}
171171

172-
public function save(string $path, string $filename = null): void
172+
public function save(string $path, string $filename = null): string
173173
{
174174
$this->generateEpub();
175-
$filename = $filename ?: Str::slugify($this->getTitle()) . '.epub';
176-
FileManager::getInstance()->compressAllTo($filename, $path);
175+
return FileManager::getInstance()->compressAllTo($this->getFilename($filename), $path);
177176
}
178177

179-
public function download()
178+
public function download(string $filename = null)
180179
{
180+
$this->generateEpub();
181+
return FileManager::getInstance()->download($this->getFilename($filename));
181182
}
182183

183184
/**
@@ -195,4 +196,9 @@ public function setTitle(string $title): void
195196
{
196197
$this->title = $title;
197198
}
199+
200+
protected function getFilename(string $filename = null): string
201+
{
202+
return $filename ?: Str::slugify($this->getTitle()) . '.epub';
203+
}
198204
}

0 commit comments

Comments
 (0)