diff --git a/app/Services/PdfMaker/PdfMakerUtilities.php b/app/Services/PdfMaker/PdfMakerUtilities.php index 174caec83fe9..56e57be52d0f 100644 --- a/app/Services/PdfMaker/PdfMakerUtilities.php +++ b/app/Services/PdfMaker/PdfMakerUtilities.php @@ -116,7 +116,8 @@ trait PdfMakerUtilities public function updateVariables(array $variables) { - $html = strtr($this->getCompiledHTML(), $variables); + $html = strtr($this->getCompiledHTML(), $variables['labels']); + $html = strtr($this->getCompiledHTML(), $variables['values']); $this->document->loadHTML($html); diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index fc922bc5f3cd..677f98137472 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -29,18 +29,14 @@ class HtmlEngine public $company; - public $designer; - public $settings; public $entity_calc; public $entity_string; - public function __construct(Designer $designer, $invitation, $entity_string) + public function __construct($invitation, $entity_string) { - $this->designer = $designer; - $this->invitation = $invitation; $this->entity = $invitation->{$entity_string}; @@ -347,7 +343,7 @@ class HtmlEngine return $data; } - private function generateLabelsAndValues() + public function generateLabelsAndValues() { $data = []; diff --git a/tests/Feature/PdfMaker/ExampleIntegrationTest.php b/tests/Feature/PdfMaker/ExampleIntegrationTest.php new file mode 100644 index 000000000000..78096a7bf95a --- /dev/null +++ b/tests/Feature/PdfMaker/ExampleIntegrationTest.php @@ -0,0 +1,36 @@ +invitations()->first(); + + $engine = new HtmlEngine($invitation, 'invoice'); + + $state = [ + 'template' => [ + + ], + 'variables' => $engine->generateLabelsAndValues(), + ]; + + $maker = new PdfMaker($state); + + $maker + ->design(Plain::class) + ->build(); + + info($state); + info($maker->getCompiledHTML()); + } +}