ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCertificateUserForObjectPreloader.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
27 private static array $certificates = [];
28
29 public function __construct(private readonly ilUserCertificateRepository $userCertificateRepository, private readonly ilCertificateActiveValidator $activeValidator)
30 {
31 }
32
33 public function preLoadDownloadableCertificates(int $objectId): void
34 {
35 if ($this->activeValidator->validate()) {
36 $objectIdsWithUserCertificate = $this->userCertificateRepository->fetchUserIdsWithCertificateForObject($objectId);
37 self::$certificates[$objectId] = $objectIdsWithUserCertificate;
38 }
39 }
40
41 public function isPreloaded(int $objId, int $userId): bool
42 {
43 if (!array_key_exists($objId, self::$certificates)) {
44 return false;
45 }
46
47 return in_array($userId, self::$certificates[$objId], true);
48 }
49}
__construct(private readonly ilUserCertificateRepository $userCertificateRepository, private readonly ilCertificateActiveValidator $activeValidator)
$objId
Definition: xapitoken.php:57