ILIAS  release_8 Revision v8.24
class.ilCertificateUserForObjectPreloader.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
27 private static array $certificates = [];
30
31 public function __construct(
34 ) {
35 $this->userCertificateRepository = $userCertificateRepository;
36 $this->activeValidator = $activeValidator;
37 }
38
39 public function preLoadDownloadableCertificates(int $objectId): void
40 {
41 if (true === $this->activeValidator->validate()) {
42 $objectIdsWithUserCertificate = $this->userCertificateRepository->fetchUserIdsWithCertificateForObject($objectId);
43 self::$certificates[$objectId] = $objectIdsWithUserCertificate;
44 }
45 }
46
47 public function isPreloaded(int $objId, int $userId): bool
48 {
49 if (false === array_key_exists($objId, self::$certificates)) {
50 return false;
51 }
52
53 if (true === in_array($userId, self::$certificates[$objId], true)) {
54 return true;
55 }
56
57 return false;
58 }
59}
__construct(ilUserCertificateRepository $userCertificateRepository, ilCertificateActiveValidator $activeValidator)
$objId
Definition: xapitoken.php:57