ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.ilUserCertificateApiGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use Psr\Http\Message\ServerRequestInterface;
22
24{
25 final public const string CMD_DOWNLOAD = 'download';
26
27 private readonly ilLogger $logger;
28 private readonly ServerRequestInterface $request;
29 private readonly ilLanguage $language;
30 private readonly ilCtrlInterface $ctrl;
31
32 public function __construct(
33 ?ilLanguage $language = null,
34 ?ServerRequestInterface $request = null,
35 ?ilLogger $logger = null,
37 ) {
38 global $DIC;
39
40 $this->language = $language ?? $DIC->language();
41 $this->request = $request ?? $DIC->http()->request();
42 $this->logger = $logger ?? $DIC->logger()->cert();
43 $this->ctrl = $ctrl ?? $DIC->ctrl();
44
45 $this->language->loadLanguageModule('cert');
46 }
47
48 public function executeCommand(): void
49 {
50 $cmd = $this->ctrl->getCmd();
51
52 switch ($cmd) {
54 $this->{$cmd}();
55 break;
56
57 default:
58 break;
59 }
60 }
61
62 public function download(): void
63 {
64 $repo = new ilUserCertificateRepository(null, $this->logger);
65
66 $certificate_id = (int) $this->request->getQueryParams()['certificate_id'];
67
68 $certificate = $repo->fetchCertificate($certificate_id);
69
70 $action = (new ilCertificatePdfAction(
71 (new ilPdfGenerator($repo))->withLogger($this->logger),
73 $this->language->txt('error_creating_certificate_pdf')
74 ))->withLogger($this->logger);
75 $action->downloadPdf(
76 $certificate->getUserId(),
77 $certificate->getObjId()
78 );
79 }
80}
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 $logger=null, ?ilCtrlInterface $ctrl=null)
readonly ServerRequestInterface $request
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26