ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilCertificatePdfAction.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
8{
12 private $logger;
13
18
23
28
33
41 public function __construct(
45 string $translatedErrorText = '',
47 ) {
48 $this->logger = $logger;
49 $this->pdfGenerator = $pdfGenerator;
50 if (null == $ilUtilHelper) {
52 }
53 $this->ilUtilHelper = $ilUtilHelper;
54
55 if (null === $errorHandler) {
56 global $DIC;
57 $errorHandler = $DIC['ilErr'];
58 }
59 $this->errorHandler = $errorHandler;
60
61 $this->translatedErrorText = $translatedErrorText;
62 }
63
70 public function createPDF(int $userId, int $objectId) : string
71 {
72 $pdfScalar = $this->pdfGenerator->generateCurrentActiveCertificate($userId, $objectId);
73
74 return $pdfScalar;
75 }
76
83 public function downloadPdf(int $userId, int $objectId) : string
84 {
85 try {
86 $pdfScalar = $this->createPDF($userId, $objectId);
87
88 $fileName = $this->pdfGenerator->generateFileName($userId, $objectId);
89
90 $this->ilUtilHelper->deliverData(
91 $pdfScalar,
92 $fileName,
93 'application/pdf'
94 );
95 } catch (ilException $clientException) {
96 $this->errorHandler->raiseError($this->translatedErrorText, $this->errorHandler->MESSAGE);
97 return '';
98 }
99
100 return $pdfScalar;
101 }
102}
An exception for terminatinating execution or to throw for unit testing.
downloadPdf(int $userId, int $objectId)
__construct(ilLogger $logger, ilPdfGenerator $pdfGenerator, ilCertificateUtilHelper $ilUtilHelper=null, string $translatedErrorText='', ilErrorHandling $errorHandler=null)
createPDF(int $userId, int $objectId)
Just a wrapper class to create Unit Test for other classes.
Base class for ILIAS Exception handling.
Component logger with individual log levels by component id.
Class ilPdfGeneratorConstantsTest.
global $DIC
Definition: saml.php:7