Minor fixes for static analysis

This commit is contained in:
David Bomba 2023-09-27 21:32:17 +10:00
parent 5e987c5ee7
commit 7281f0f281
4 changed files with 25 additions and 13 deletions

View File

@ -375,8 +375,9 @@ class PreviewController extends BaseController
];
$ts = (new TemplateService());
$ts->setTemplate($design_object)
->build($data);
$ts->setCompany($company)
->setTemplate($design_object)
->build($data);
$html = $ts->getHtml();

View File

@ -79,6 +79,6 @@ class Design extends BaseModel
public function service(): TemplateService
{
return new TemplateService($this);
return (new TemplateService($this))->setCompany($this->company);
}
}

File diff suppressed because one or more lines are too long

View File

@ -15,6 +15,7 @@ use App\Models\Task;
use App\Models\Quote;
use App\Models\Credit;
use App\Models\Design;
use App\Models\Company;
use App\Models\Payment;
use App\Models\Project;
use App\Utils\HtmlEngine;
@ -45,6 +46,8 @@ class TemplateService
private array $data = [];
public ?Company $company;
public function __construct(public ?Design $template = null)
{
$this->template = $template;
@ -89,6 +92,11 @@ class TemplateService
public function mock(): self
{
$tm = new TemplateMock($this->company);
$this->data = $tm->engines;
$this->parseNinjaBlocks()
->parseVariables($tm->variables);
return $this;
}
@ -103,8 +111,6 @@ class TemplateService
$this->data = $this->preProcessDataBlocks($data);
nlog(json_encode($this->data));
return $this;
}
@ -424,4 +430,16 @@ class TemplateService
return $i[PurchaseOrder::class];
}
public function setCompany(Company $company): self
{
$this->company = $company;
return $this;
}
public function getCompany(): Company
{
return $this->company;
}
}