ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ilPdfGenerator Class Reference
+ Collaboration diagram for ilPdfGenerator:

Public Member Functions

 __construct (private readonly ilUserCertificateRepository $repository, private ?IRSS $irss=null, private ?ilCertificateRpcClientFactoryHelper $rpc=null, private ?ilCertificatePdfFileNameFactory $filename_factory=null, ?ilLanguage $lng=null)
 
 withLogger (ilLogger $logger)
 
 generate (int $userCertificateId)
 
 generateCurrentActiveCertificate (int $userId, int $objId)
 
 generateFileName (int $userId, int $objId)
 

Private Member Functions

 createPDFScalar (ilUserCertificate $certificate)
 

Private Attributes

ilLogger $logger = null
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilPdfGenerator::__construct ( private readonly ilUserCertificateRepository  $repository,
private ?IRSS  $irss = null,
private ?ilCertificateRpcClientFactoryHelper  $rpc = null,
private ?ilCertificatePdfFileNameFactory  $filename_factory = null,
?ilLanguage  $lng = null 
)

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

34 {
35 global $DIC;
36
37 $this->irss = $irss ?? $DIC->resourceStorage();
38 $this->rpc = $rpc ?? new ilCertificateRpcClientFactoryHelper();
39 $this->filename_factory = $filename_factory ?? new ilCertificatePdfFileNameFactory(
40 $lng ?? $DIC->language()
41 );
42 }
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26

References $DIC, and $lng.

Member Function Documentation

◆ createPDFScalar()

ilPdfGenerator::createPDFScalar ( ilUserCertificate  $certificate)
private

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

89 : string
90 {
91 $content = $certificate->getCertificateContent();
92
93 $this->logger?->debug(
94 'Delegating certificate PDF generation for certificate id {certificate_id} (user {user_id} and object {object_id}) to ilServer',
95 [
96 'certificate_id' => $certificate->getCertificateId()->asString(),
97 'user_id' => $certificate->getUserId(),
98 'object_id' => $certificate->getObjId()
99 ]
100 );
101
102
103 $background_rid = $this->irss->manage()->find($certificate->getBackgroundImageIdentification());
104 if ($background_rid instanceof ResourceIdentification) {
105 $background_src = $this->irss->consume()->src($background_rid)->getSrc(true);
106
107 $content = str_replace(
108 ['[BACKGROUND_IMAGE]'],
109 [$background_src],
110 $content
111 );
112 }
113
114 $pdf_base64 = $this->rpc->ilFO2PDF('RPCTransformationHandler', $content);
115
116 $size = strlen(base64_decode($pdf_base64->scalar, true));
117 $this->logger?->debug(
118 'Received generated PDF with size {size} bytes for certificate id {certificate_id} (user {user_id} and object {object_id}) from ilServer',
119 [
120 'size' => $size,
121 'certificate_id' => $certificate->getCertificateId()->asString(),
122 'user_id' => $certificate->getUserId(),
123 'object_id' => $certificate->getObjId()
124 ]
125 );
126
127
128 return $pdf_base64->scalar;
129 }

References ilUserCertificate\getBackgroundImageIdentification(), ilUserCertificate\getCertificateContent(), ilUserCertificate\getCertificateId(), ilUserCertificate\getObjId(), ilUserCertificate\getUserId(), and ILIAS\Repository\logger().

Referenced by generate(), and generateCurrentActiveCertificate().

+ 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 55 of file class.ilPdfGenerator.php.

55 : string
56 {
57 $certificate = $this->repository->fetchCertificate($userCertificateId);
58
59 return $this->createPDFScalar($certificate);
60 }
createPDFScalar(ilUserCertificate $certificate)

References createPDFScalar(), and ILIAS\UI\examples\Deck\repository().

+ Here is the call graph for this function:

◆ generateCurrentActiveCertificate()

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

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

65 : string
66 {
67 $certificate = $this->repository->fetchActiveCertificate($userId, $objId);
68
69 return $this->createPDFScalar($certificate);
70 }
$objId
Definition: xapitoken.php:55

References $objId, createPDFScalar(), and ILIAS\UI\examples\Deck\repository().

+ Here is the call graph for this function:

◆ generateFileName()

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

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

77 : string
78 {
79 $certificate = $this->repository->fetchActiveCertificateForPresentation($userId, $objId);
80
82 if (!$user instanceof ilObjUser) {
83 throw new ilException(sprintf('The usr_id "%s" does NOT reference a user', $userId));
84 }
85
86 return $this->filename_factory->create($certificate);
87 }
Base class for ILIAS Exception handling.
User class.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id

References $objId, ilObjectFactory\getInstanceByObjId(), and ILIAS\UI\examples\Deck\repository().

+ Here is the call graph for this function:

◆ withLogger()

ilPdfGenerator::withLogger ( ilLogger  $logger)

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

44 : self
45 {
46 $clone = clone $this;
47 $clone->logger = $logger;
48
49 return $clone;
50 }

References $logger.

Field Documentation

◆ $logger

ilLogger ilPdfGenerator::$logger = null
private

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

Referenced by withLogger().


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