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 
17  private $pdfGenerator;
18 
22  private $ilUtilHelper;
23 
27  private $errorHandler;
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 }
Class ilPdfGeneratorConstantsTest.
global $DIC
Definition: saml.php:7
__construct(ilLogger $logger, ilPdfGenerator $pdfGenerator, ilCertificateUtilHelper $ilUtilHelper=null, string $translatedErrorText='', ilErrorHandling $errorHandler=null)
Just a wrapper class to create Unit Test for other classes.
createPDF(int $userId, int $objectId)
Component logger with individual log levels by component id.
downloadPdf(int $userId, int $objectId)