ILIAS  release_8 Revision v8.24
class.ilUserCertificateApiGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use Psr\Http\Message\ServerRequestInterface;
22
28{
29 public const CMD_DOWNLOAD = 'download';
31 private ServerRequestInterface $request;
34
35 public function __construct(
36 ?ilLanguage $language = null,
37 ?ServerRequestInterface $request = null,
40 ) {
41 global $DIC;
42
43 if ($language === null) {
44 $language = $DIC->language();
45 }
46 $this->language = $language;
47
48 if ($request === null) {
49 $request = $DIC->http()->request();
50 }
51 $this->request = $request;
52
53 if ($certificateLogger === null) {
54 $certificateLogger = $DIC->logger()->cert();
55 }
56 $this->certificateLogger = $certificateLogger;
57
58 if ($ctrl === null) {
59 $ctrl = $DIC->ctrl();
60 }
61 $this->ctrl = $ctrl;
62
63 $this->language->loadLanguageModule('cert');
64 }
65
66 public function executeCommand(): void
67 {
68 $cmd = $this->ctrl->getCmd();
69
70 switch ($cmd) {
72 $this->{$cmd}();
73 break;
74
75 default:
76 break;
77 }
78 }
79
80 public function download(): void
81 {
82 $userCertificateRepository = new ilUserCertificateRepository(null, $this->certificateLogger);
83 $pdfGenerator = new ilPdfGenerator($userCertificateRepository, $this->certificateLogger);
84
85 $userCertificateId = (int) $this->request->getQueryParams()['certificate_id'];
86
87 $userCertificate = $userCertificateRepository->fetchCertificate($userCertificateId);
88
89 $pdfAction = new ilCertificatePdfAction(
90 $this->certificateLogger,
91 $pdfGenerator,
93 $this->language->txt('error_creating_certificate_pdf')
94 );
95
96 $pdfAction->downloadPdf($userCertificate->getUserId(), $userCertificate->getObjId());
97 }
98}
Just a wrapper class to create Unit Test for other classes.
language handling
Component logger with individual log levels by component id.
__construct(?ilLanguage $language=null, ?ServerRequestInterface $request=null, ?ilLogger $certificateLogger=null, ?ilCtrlInterface $ctrl=null)
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilPdfGeneratorConstantsTest.