ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCertificatePdfAction.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
28
29 public function __construct(
30 private readonly ilPdfGenerator $pdfGenerator,
32 private readonly string $translatedErrorText = '',
34 ) {
35 if (null === $ilUtilHelper) {
37 }
38 $this->ilUtilHelper = $ilUtilHelper;
39
40 if (null === $errorHandler) {
41 global $DIC;
42 $errorHandler = $DIC['ilErr'];
43 }
44 $this->errorHandler = $errorHandler;
45 }
46
47 public function createPDF(int $userId, int $objectId): string
48 {
49 return $this->pdfGenerator->generateCurrentActiveCertificate($userId, $objectId);
50 }
51
52 public function downloadPdf(int $userId, int $objectId): string
53 {
54 try {
55 $pdfScalar = $this->createPDF($userId, $objectId);
56
57 $fileName = $this->pdfGenerator->generateFileName($userId, $objectId);
58
59 $this->ilUtilHelper->deliverData(
60 $pdfScalar,
61 $fileName,
62 'application/pdf'
63 );
64 } catch (ilException) {
65 $this->errorHandler->raiseError($this->translatedErrorText, $this->errorHandler->MESSAGE);
66 return '';
67 }
68
69 return $pdfScalar;
70 }
71}
downloadPdf(int $userId, int $objectId)
readonly ilCertificateUtilHelper $ilUtilHelper
createPDF(int $userId, int $objectId)
__construct(private readonly ilPdfGenerator $pdfGenerator, ?ilCertificateUtilHelper $ilUtilHelper=null, private readonly string $translatedErrorText='', ?ilErrorHandling $errorHandler=null)
readonly ilErrorHandling $errorHandler
Just a wrapper class to create Unit Test for other classes.
Error Handling & global info handling.
Base class for ILIAS Exception handling.
global $DIC
Definition: shib_login.php:26