ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilPdfGenerator Class Reference
+ Collaboration diagram for ilPdfGenerator:

Public Member Functions

 __construct (private readonly ilUserCertificateRepository $certificateRepository, ?ilCertificateRpcClientFactoryHelper $rpcHelper=null, ?ilCertificatePdfFileNameFactory $pdfFileNameFactory=null, ?ilLanguage $lng=null, ?ilCertificateMathJaxHelper $mathJaxHelper=null)
 
 generate (int $userCertificateId)
 
 generateCurrentActiveCertificate (int $userId, int $objId)
 
 generateFileName (int $userId, int $objId)
 

Private Member Functions

 createPDFScalar (ilUserCertificate $certificate)
 

Private Attributes

readonly ilCertificateRpcClientFactoryHelper $rpcHelper
 
readonly ilCertificateMathJaxHelper $mathJaxHelper
 
readonly ilCertificatePdfFileNameFactory $pdfFilenameFactory
 

Detailed Description

Author
Niels Theen nthee.nosp@m.n@da.nosp@m.tabay.nosp@m..de

Definition at line 24 of file class.ilPdfGenerator.php.

Constructor & Destructor Documentation

◆ __construct()

ilPdfGenerator::__construct ( private readonly ilUserCertificateRepository  $certificateRepository,
?ilCertificateRpcClientFactoryHelper  $rpcHelper = null,
?ilCertificatePdfFileNameFactory  $pdfFileNameFactory = null,
?ilLanguage  $lng = null,
?ilCertificateMathJaxHelper  $mathJaxHelper = null 
)

Definition at line 30 of file class.ilPdfGenerator.php.

References $DIC, $lng, $mathJaxHelper, and $rpcHelper.

36  {
37  global $DIC;
38 
39  if (null === $rpcHelper) {
41  }
42  $this->rpcHelper = $rpcHelper;
43 
44  if (null === $mathJaxHelper) {
46  }
47  $this->mathJaxHelper = $mathJaxHelper;
48 
49  if (null === $lng) {
50  $lng = $DIC->language();
51  }
52 
53  if (null === $pdfFileNameFactory) {
54  $pdfFileNameFactory = new ilCertificatePdfFileNameFactory($lng);
55  }
56  $this->pdfFilenameFactory = $pdfFileNameFactory;
57  }
readonly ilCertificateMathJaxHelper $mathJaxHelper
global $DIC
Definition: feed.php:28
$lng
readonly ilCertificateRpcClientFactoryHelper $rpcHelper

Member Function Documentation

◆ createPDFScalar()

ilPdfGenerator::createPDFScalar ( ilUserCertificate  $certificate)
private

Definition at line 96 of file class.ilPdfGenerator.php.

References CLIENT_WEB_DIR, ilUserCertificate\getBackgroundImagePath(), and ilUserCertificate\getCertificateContent().

Referenced by generate(), and generateCurrentActiveCertificate().

96  : string
97  {
98  $certificateContent = $certificate->getCertificateContent();
99 
100  $certificateContent = str_replace(
101  ['[BACKGROUND_IMAGE]', '[CLIENT_WEB_DIR]'],
102  ['[CLIENT_WEB_DIR]' . $certificate->getBackgroundImagePath(), 'file://' . CLIENT_WEB_DIR],
103  $certificateContent
104  );
105 
106  $certificateContent = $this->mathJaxHelper->fillXlsFoContent($certificateContent);
107 
108  $pdf_base64 = $this->rpcHelper->ilFO2PDF('RPCTransformationHandler', $certificateContent);
109 
110  return $pdf_base64->scalar;
111  }
const CLIENT_WEB_DIR
Definition: constants.php:47
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generate()

ilPdfGenerator::generate ( int  $userCertificateId)
Exceptions
ilException

Definition at line 62 of file class.ilPdfGenerator.php.

References createPDFScalar().

62  : string
63  {
64  $certificate = $this->certificateRepository->fetchCertificate($userCertificateId);
65 
66  return $this->createPDFScalar($certificate);
67  }
createPDFScalar(ilUserCertificate $certificate)
+ Here is the call graph for this function:

◆ generateCurrentActiveCertificate()

ilPdfGenerator::generateCurrentActiveCertificate ( int  $userId,
int  $objId 
)
Exceptions
ilException

Definition at line 72 of file class.ilPdfGenerator.php.

References createPDFScalar().

72  : string
73  {
74  $certificate = $this->certificateRepository->fetchActiveCertificate($userId, $objId);
75 
76  return $this->createPDFScalar($certificate);
77  }
$objId
Definition: xapitoken.php:57
createPDFScalar(ilUserCertificate $certificate)
+ Here is the call graph for this function:

◆ generateFileName()

ilPdfGenerator::generateFileName ( int  $userId,
int  $objId 
)
Exceptions
ilDatabaseException
ilException
ilObjectNotFoundException

Definition at line 84 of file class.ilPdfGenerator.php.

References ilObjectFactory\getInstanceByObjId().

84  : string
85  {
86  $certificate = $this->certificateRepository->fetchActiveCertificateForPresentation($userId, $objId);
87 
88  $user = ilObjectFactory::getInstanceByObjId($userId);
89  if (!$user instanceof ilObjUser) {
90  throw new ilException(sprintf('The usr_id "%s" does NOT reference a user', $userId));
91  }
92 
93  return $this->pdfFilenameFactory->create($certificate);
94  }
$objId
Definition: xapitoken.php:57
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:

Field Documentation

◆ $mathJaxHelper

readonly ilCertificateMathJaxHelper ilPdfGenerator::$mathJaxHelper
private

Definition at line 27 of file class.ilPdfGenerator.php.

Referenced by __construct().

◆ $pdfFilenameFactory

readonly ilCertificatePdfFileNameFactory ilPdfGenerator::$pdfFilenameFactory
private

Definition at line 28 of file class.ilPdfGenerator.php.

◆ $rpcHelper

readonly ilCertificateRpcClientFactoryHelper ilPdfGenerator::$rpcHelper
private

Definition at line 26 of file class.ilPdfGenerator.php.

Referenced by __construct().


The documentation for this class was generated from the following file: