pdf title name-placeholder
This commit is contained in:
@@ -73,8 +73,9 @@ class EntityProcessor
|
||||
}
|
||||
|
||||
if ($template->hasTitle()) {
|
||||
// @todo Support placeholders.
|
||||
$pdf->SetTitle($template->getTitle());
|
||||
$title = $this->replacePlaceholders($template->getTitle(), $entity);
|
||||
|
||||
$pdf->SetTitle($title);
|
||||
}
|
||||
|
||||
$pdf->setFont($fontFace, '', $this->fontSize, '', true);
|
||||
@@ -230,4 +231,19 @@ class EntityProcessor
|
||||
|
||||
return "<tcpdf method=\"{$function}\" params=\"{$paramsString}\" />";
|
||||
}
|
||||
|
||||
private function replacePlaceholders(string $string, Entity $entity): string
|
||||
{
|
||||
$newString = $string;
|
||||
|
||||
$attributeList = ['name'];
|
||||
|
||||
foreach ($attributeList as $attribute) {
|
||||
$value = (string) ($entity->get($attribute) ?? '');
|
||||
|
||||
$newString = str_replace('{$' . $attribute . '}', $value, $newString);
|
||||
}
|
||||
|
||||
return $newString;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user