Zuerst etwas config:
'view_helpers' => [ 'aliases' => [ ], 'factories' => [ FooterHtml::class => FooterHtmlFactory::class, ],
In einer Factory den ViewHelperManager/HelperPluginManager holen und ausführen:
/** @var HelperPluginManager $pluginManager */ $pluginManager = $container->get('ViewHelperManager'); /** @var FooterHtml $footerHtml */ $footerHtml = $pluginManager->get(FooterHtml::class); $some->setUserdataFooterHtml($footerHtml());
Und der ViewHelper:
class FooterHtml extends AbstractViewHelper { const TEMPLATE = 'lerpDocumentTcpdf/footerHtml'; protected string $brandColor; public function setBrandColor(string $brandColor): void { $this->brandColor = $brandColor; } /** * @return string */ public function __invoke(): string { $viewModel = new ViewModel(); $viewModel->setTemplate(self::TEMPLATE); $viewModel->setVariable('colorBrand', $this->brandColor); return $this->getView()->render($viewModel); } }