. */ namespace App\Services\LabelSystem; use App\Entity\Contracts\NamedElementInterface; use App\Entity\LabelSystem\LabelOptions; use App\Services\ElementTypeNameGenerator; use Twig\Environment; class LabelHTMLGenerator { protected $twig; protected $elementTypeNameGenerator; protected $replacer; public function __construct(ElementTypeNameGenerator $elementTypeNameGenerator, LabelTextReplacer $replacer, Environment $twig) { $this->twig = $twig; $this->elementTypeNameGenerator = $elementTypeNameGenerator; $this->replacer = $replacer; } public function getLabelHTML(LabelOptions $options, object $element): string { return $this->twig->render('LabelSystem/labels/base_label.html.twig', [ 'meta_title' => $this->getPDFTitle($options, $element), 'lines' => $this->replacer->replace($options->getLines(), $element), ]); } protected function getPDFTitle(LabelOptions $options, object $element) { if ($element instanceof NamedElementInterface) { return $this->elementTypeNameGenerator->getTypeNameCombination($element, false); } return 'Part-DB label'; } }