Functionality to inject the setting if it doesn't exists

This commit is contained in:
Benjamin Beganović 2021-08-24 16:06:34 +02:00
parent 7639746178
commit 00dbec0ce1

View File

@ -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.
*