From 00dbec0ce16b199bd9386e8e6b9128506de4ec4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Tue, 24 Aug 2021 16:06:34 +0200 Subject: [PATCH] Functionality to inject the setting if it doesn't exists --- .../PdfMaker/Designs/Utilities/DesignHelpers.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php index 9fea0b23cd10..b9aea8184d42 100644 --- a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php +++ b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php @@ -28,6 +28,8 @@ trait DesignHelpers public function setup(): self { + $this->syncPdfVariables(); + if (isset($this->context['client'])) { $this->client = $this->context['client']; } @@ -54,6 +56,20 @@ trait DesignHelpers return $this; } + protected function syncPdfVariables(): void + { + $default = (array) \App\DataMapper\CompanySettings::getEntityVariableDefaults(); + $variables = $this->context['pdf_variables']; + + foreach ($default as $property => $value) { + if (array_key_exists($property, $variables)) { + continue; + } + + $variables[$property] = $value; + } + } + /** * Initialize local dom document instance. Used for getting raw HTML out of template. *