ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilPRGCertificateHelper.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 protected \ilLogger $log;
24 protected \ilCertificateTemplateRepository $certificate_template_repository;
25 protected \ilCertificateTypeClassMap $certificate_type_class_map;
26 protected \ilCertificateCron $certificate_cron;
28
29 public function init(): void
30 {
31 global $DIC;
32 $this->log = $DIC['ilLog'];
33 $this->certificate_type_class_map = new ilCertificateTypeClassMap();
34 $this->certificate_template_repository = new ilCertificateTemplateDatabaseRepository($DIC->database());
35 $this->certificate_cron = new ilCertificateCron();
36 }
37
38 public function updateCertificateForPrg(
39 int $obj_id,
40 int $usr_id
41 ): bool {
42 try {
43 $this->init();
44 $class_name = $this->certificate_type_class_map->getPlaceHolderClassNameByType('prg');
45 $template = $this->certificate_template_repository->fetchCurrentlyActiveCertificate($obj_id);
46
47 $this->processEntry(
48 $class_name,
49 $obj_id,
50 $usr_id,
51 $template
52 );
53
54 return true;
55 } catch (\ilException $exception) {
56 $this->log->warning($exception->getMessage());
57 return false;
58 }
59 }
60
61 public function removeCertificateForUser(
62 int $node_id,
63 int $usr_id,
64 ): void {
67 }
68
69 private function processEntry(
70 string $class_name,
71 int $obj_id,
72 int $usr_id,
73 \ilCertificateTemplate $template
74 ): void {
75 $entry = new \ilCertificateQueueEntry(
76 $obj_id,
77 $usr_id,
78 $class_name,
79 \ilCronConstants::IN_PROGRESS,
80 (int) $template->getId(),
81 time()
82 );
83 $this->certificate_cron->init();
84 $this->certificate_cron->processEntry(0, $entry, []);
85 }
86}
Base class for ILIAS Exception handling.
deleteUserCertificatesForObject(int $userId, int $obj_id)
ilCertificateTypeClassMap $certificate_type_class_map
updateCertificateForPrg(int $obj_id, int $usr_id)
ilUserCertificateRepository $user_certificate_repository
processEntry(string $class_name, int $obj_id, int $usr_id, \ilCertificateTemplate $template)
ilCertificateCron $certificate_cron
trait ilPRGCertificateHelper
removeCertificateForUser(int $node_id, int $usr_id,)
ilCertificateTemplateRepository $certificate_template_repository
$log
Definition: ltiresult.php:34
try
handle Lrs Init
Definition: xapiproxy.php:86
global $DIC
Definition: shib_login.php:26