From: Vincent Vanwaelscappel Date: Mon, 22 Aug 2022 15:28:07 +0000 (+0200) Subject: wip #5408 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=3376a4c81eacb13f42c3e4d9af38d40e0e508af4;p=fluidbook_tools.git wip #5408 @0.5 --- diff --git a/src/Compiler/Compiler.php b/src/Compiler/Compiler.php index 7d37b8c..38c8cb7 100644 --- a/src/Compiler/Compiler.php +++ b/src/Compiler/Compiler.php @@ -22,23 +22,21 @@ use JsonException; class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface { + use FluidbookCompiler; + use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Links; use Styles; - /** @var VirtualDirectory */ - protected $vdir; + /** * @var string */ protected $out; - /** - * @var Data - */ - public $config; + /** * @var Source[] @@ -50,10 +48,7 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface */ protected $pages = []; - /** - * @var string - */ - public $wdir = ''; + /** * @var string @@ -75,11 +70,6 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface } } - public function getVirtualDirectory() : VirtualDirectory - { - return $this->vdir; - } - /** * Execute the job. @@ -177,8 +167,7 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface start_measure('Compile fluidbook'); if ($this->wdir === '') { - $this->wdir = storage_path('fluidbook/working/'); - Files::mkdir($this->wdir); + $this->wdir = Files::mkdir(storage_path('fluidbook/working')); } $this->vdir = new VirtualDirectory($this->out); @@ -364,13 +353,5 @@ class Compiler implements ShouldQueue, ShouldBeUnique, CompilerInterface // TODO: Implement addContentLock() method. } - public function getSetting($key, $default = null) - { - return $this->config->get($key, $default); - } - public function setSetting($key, $value) - { - $this->config->set($key, $value); - } } diff --git a/src/Compiler/CompilerInterface.php b/src/Compiler/CompilerInterface.php index ae4a3c3..e8f3edb 100644 --- a/src/Compiler/CompilerInterface.php +++ b/src/Compiler/CompilerInterface.php @@ -24,4 +24,8 @@ interface CompilerInterface * @return VirtualDirectory */ public function getVirtualDirectory(): VirtualDirectory; + + public function getWorkingDir(): string; + + public function setWorkingDir(string $wdir); } diff --git a/src/Compiler/FluidbookCompiler.php b/src/Compiler/FluidbookCompiler.php new file mode 100644 index 0000000..d2fab22 --- /dev/null +++ b/src/Compiler/FluidbookCompiler.php @@ -0,0 +1,58 @@ +vdir; + } + + /** + * @param VirtualDirectory $vdir + */ + public function setVirtualDirectory(VirtualDirectory $vdir): void + { + $this->vdir = $vdir; + } + + public function getWorkingDir(): string + { + return $this->wdir; + } + + public function setWorkingDir(string $wdir) + { + $this->wdir = $wdir; + } + + public function working_path($path = '') + { + $res = $this->getWorkingDir(); + return $path ? $res . '/' . $path : $res; + } + + public function getSetting($key, $default = null) + { + return $this->config->get($key, $default); + } + + public function setSetting($key, $value) + { + $this->config->set($key, $value); + } +} diff --git a/src/Links/DownloadPortionLink.php b/src/Links/DownloadPortionLink.php index c072e07..2268b2d 100644 --- a/src/Links/DownloadPortionLink.php +++ b/src/Links/DownloadPortionLink.php @@ -17,7 +17,7 @@ class DownloadPortionLink extends FileLink { $pdf = $this->compiler->getSetting('downloadPortionPDF', ''); if ($pdf !== '') { - $pdf = $this->compiler->wdir . '/' . $pdf; + $pdf = $this->compiler->getWorkingDir() . '/' . $pdf; } $res = [