Allow to generate multiple labels at once (multiple pages in 1 PDF file).

This commit is contained in:
Jan Böhmer 2020-04-21 00:00:29 +02:00
parent 4c5820ee22
commit e89cc4bb01
12 changed files with 389 additions and 228 deletions

View file

@ -38,11 +38,23 @@ class LabelHTMLGenerator
$this->replacer = $replacer;
}
public function getLabelHTML(LabelOptions $options, object $element): string
public function getLabelHTML(LabelOptions $options, array $elements): string
{
if (empty($elements)) {
throw new \InvalidArgumentException('$elements must not be empty');
}
$twig_elements = [];
foreach ($elements as $element) {
$twig_elements[] = [
'element' => $element,
'lines' => $this->replacer->replace($options->getLines(), $element)
];
}
return $this->twig->render('LabelSystem/labels/base_label.html.twig', [
'meta_title' => $this->getPDFTitle($options, $element),
'lines' => $this->replacer->replace($options->getLines(), $element),
'meta_title' => $this->getPDFTitle($options, $elements[0]),
'elements' => $twig_elements,
]);
}