ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilCertificateObjectsForUserPreloader.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
8 {
10  private static $certificates = [];
11 
14 
20  {
21  $this->userCertificateRepository = $userCertificateRepository;
22  }
23 
28  public function preLoad(int $userId, array $objIds)
29  {
30  if (!array_key_exists($userId, self::$certificates)) {
31  self::$certificates[$userId] = [];
32  }
33 
34  $objectIdsWithUserCertificate = $this->userCertificateRepository->fetchObjectIdsWithCertificateForUser(
35  $userId,
36  array_diff($objIds, self::$certificates[$userId])
37  );
38 
39  self::$certificates[$userId] = array_unique(array_merge(
40  $objectIdsWithUserCertificate,
41  self::$certificates[$userId]
42  ));
43  }
44 
50  public function isPreloaded(int $userId, int $objId) : bool
51  {
52  if (false === array_key_exists($userId, self::$certificates)) {
53  return false;
54  }
55 
56  if (true === in_array($objId, self::$certificates[$userId])) {
57  return true;
58  }
59 
60  return false;
61  }
62 }
$certificates
Definition: metarefresh.php:39
__construct(ilUserCertificateRepository $userCertificateRepository)
ilCertificateObjectsForUserPreloader constructor.