service = $service; } /** * @throws Error * @throws Forbidden */ public function generate(Entity $entity, Template $template, ?Params $params = null, ?Data $data = null): string { $additionalData = null; if ($data) { $additionalData = get_object_vars($data->getAdditionalTemplateData()); } return $this->buildFromTemplate($entity, $template, false, $additionalData); } /** * @param ?array $additionalData * @throws Error * @throws Forbidden * @throws NotFound * * @deprecated Left for bc. */ public function buildFromTemplate( Entity $entity, Template $template, bool $displayInline = false, ?array $additionalData = null ): string { $data = Data::create() ->withAdditionalTemplateData( (object) ($additionalData ?? []) ); $contents = $this->service->generate( $entity->getEntityType(), $entity->getId(), $template->getId(), null, $data ); return $contents->getString(); } }