ILIAS  release_8 Revision v8.24
class.ilCertificatePdfAction.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
30 private string $translatedErrorText;
31
32 public function __construct(
36 string $translatedErrorText = '',
38 ) {
39 $this->logger = $logger;
40 $this->pdfGenerator = $pdfGenerator;
41 if (null === $ilUtilHelper) {
43 }
44 $this->ilUtilHelper = $ilUtilHelper;
45
46 if (null === $errorHandler) {
47 global $DIC;
48 $errorHandler = $DIC['ilErr'];
49 }
50 $this->errorHandler = $errorHandler;
51
52 $this->translatedErrorText = $translatedErrorText;
53 }
54
55 public function createPDF(int $userId, int $objectId): string
56 {
57 return $this->pdfGenerator->generateCurrentActiveCertificate($userId, $objectId);
58 }
59
60 public function downloadPdf(int $userId, int $objectId): string
61 {
62 try {
63 $pdfScalar = $this->createPDF($userId, $objectId);
64
65 $fileName = $this->pdfGenerator->generateFileName($userId, $objectId);
66
67 $this->ilUtilHelper->deliverData(
68 $pdfScalar,
69 $fileName,
70 'application/pdf'
71 );
72 } catch (ilException $clientException) {
73 $this->errorHandler->raiseError($this->translatedErrorText, $this->errorHandler->MESSAGE);
74 return '';
75 }
76
77 return $pdfScalar;
78 }
79}
downloadPdf(int $userId, int $objectId)
__construct(ilLogger $logger, ilPdfGenerator $pdfGenerator, ?ilCertificateUtilHelper $ilUtilHelper=null, string $translatedErrorText='', ?ilErrorHandling $errorHandler=null)
ilCertificateUtilHelper $ilUtilHelper
createPDF(int $userId, int $objectId)
Just a wrapper class to create Unit Test for other classes.
Error Handling & global info handling uses PEAR error class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Component logger with individual log levels by component id.
global $DIC
Definition: feed.php:28
Class ilPdfGeneratorConstantsTest.