ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilUserCertificateApiGUI.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4use Psr\Http\Message\ServerRequestInterface;
5
11{
12 const CMD_DOWNLOAD = 'download';
13
16
18 private $request;
19
21 private $language;
22
24 private $controller;
25
32 public function __construct(
33 ilLanguage $language = null,
34 ServerRequestInterface $request = null,
36 ilCtrl $controller = null
37 ) {
38 global $DIC;
39
40 if ($language === null) {
41 $language = $DIC->language();
42 }
43 $this->language = $language;
44
45 if ($request === null) {
46 $request = $DIC->http()->request();
47 }
48 $this->request = $request;
49
50 if ($certificateLogger === null) {
51 $certificateLogger = $DIC->logger()->cert();
52 }
53 $this->certificateLogger = $certificateLogger;
54
55 if ($controller === null) {
56 $controller = $DIC->ctrl();
57 }
58 $this->controller = $controller;
59
60
61 $this->language->loadLanguageModule('cert');
62 }
63
64
68 public function executeCommand() : void
69 {
70 $cmd = $this->controller->getCmd();
71
72 switch ($cmd) {
74 $this->{$cmd}();
75 break;
76
77 default:
78 break;
79 }
80 }
81
82
86 public function download() : void
87 {
88 $userCertificateRepository = new ilUserCertificateRepository(null, $this->certificateLogger);
89 $pdfGenerator = new ilPdfGenerator($userCertificateRepository, $this->certificateLogger);
90
91 $userCertificateId = (int) $this->request->getQueryParams()['certificate_id'];
92
93 $userCertificate = $userCertificateRepository->fetchCertificate($userCertificateId);
94
95 $pdfAction = new ilCertificatePdfAction(
96 $this->certificateLogger,
97 $pdfGenerator,
99 $this->language->txt('error_creating_certificate_pdf')
100 );
101
102 $pdfAction->downloadPdf($userCertificate->getUserId(), $userCertificate->getObjId());
103 }
104}
An exception for terminatinating execution or to throw for unit testing.
Just a wrapper class to create Unit Test for other classes.
This class provides processing control methods.
language handling
Component logger with individual log levels by component id.
__construct(ilLanguage $language=null, ServerRequestInterface $request=null, ilLogger $certificateLogger=null, ilCtrl $controller=null)
global $DIC
Definition: goto.php:24
language()
Definition: language.php:2
Class ilPdfGeneratorConstantsTest.