diff --git a/app/Services/Pdf/PdfService.php b/app/Services/Pdf/PdfService.php index 306bc92f0f9d..043adcf85a9a 100644 --- a/app/Services/Pdf/PdfService.php +++ b/app/Services/Pdf/PdfService.php @@ -12,6 +12,7 @@ namespace App\Services\Pdf; use App\Services\Pdf\PdfConfiguration; +use App\Utils\HtmlEngine; class PdfService { @@ -20,6 +21,12 @@ class PdfService public PdfConfiguration $config; + public PdfBuilder $builder; + + public PdfDesigner $designer; + + public array $html_variables; + public function __construct($invitation) { @@ -27,6 +34,17 @@ class PdfService $this->config = (new PdfConfiguration($this))->init(); + $this->html_variables = (new HtmlEngine($invitation))->generateLabelsAndValues(); + + $this->builder = (new PdfBuilder($this)); + + $this->designer = (new PdfDesigner($this))->build(); + } + + public function build() + { + $this->builder->build(); + } public function getPdf() @@ -39,4 +57,30 @@ class PdfService } + + // $state = [ + // 'template' => $template->elements([ + // 'client' => $this->client, + // 'entity' => $this->entity, + // 'pdf_variables' => (array) $this->company->settings->pdf_variables, + // '$product' => $design->design->product, + // 'variables' => $variables, + // ]), + // 'variables' => $variables, + // 'options' => [ + // 'all_pages_header' => $this->entity->client->getSetting('all_pages_header'), + // 'all_pages_footer' => $this->entity->client->getSetting('all_pages_footer'), + // ], + // 'process_markdown' => $this->entity->client->company->markdown_enabled, + // ]; + + // $maker = new PdfMakerService($state); + + // $maker + // ->design($template) + // ->build(); + + + + } \ No newline at end of file diff --git a/tests/Pdf/PdfServiceTest.php b/tests/Pdf/PdfServiceTest.php index 30371619b10e..b4d39ba936b4 100644 --- a/tests/Pdf/PdfServiceTest.php +++ b/tests/Pdf/PdfServiceTest.php @@ -65,4 +65,24 @@ class PdfServiceTest extends TestCase $this->assertEquals(2, $service->config->design->id); } + + public function testHtmlIsArray() + { + $invitation = $this->invoice->invitations->first(); + + $service = new PdfService($invitation); + + $this->assertIsArray($service->html_variables); + + } + + public function testTemplateResolution() + { + $invitation = $this->invoice->invitations->first(); + + $service = new PdfService($invitation); + + $this->assertIsString($service->designer->template); + + } } \ No newline at end of file