ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCertificateObjectsForUserPreloader Class Reference
+ Collaboration diagram for ilCertificateObjectsForUserPreloader:

Public Member Functions

 __construct (ilUserCertificateRepository $userCertificateRepository)
 ilCertificateObjectsForUserPreloader constructor. More...
 
 preLoad (int $userId, array $objIds)
 
 isPreloaded (int $userId, int $objId)
 

Private Attributes

 $userCertificateRepository
 

Static Private Attributes

static $certificates = []
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCertificateObjectsForUserPreloader::__construct ( ilUserCertificateRepository  $userCertificateRepository)

ilCertificateObjectsForUserPreloader constructor.

Parameters
ilUserCertificateRepository$userCertificateRepository

Definition at line 19 of file class.ilCertificateObjectsForUserPreloader.php.

References $userCertificateRepository.

20  {
21  $this->userCertificateRepository = $userCertificateRepository;
22  }

Member Function Documentation

◆ isPreloaded()

ilCertificateObjectsForUserPreloader::isPreloaded ( int  $userId,
int  $objId 
)
Parameters
int$userId
int$objId
Returns
bool

Definition at line 50 of file class.ilCertificateObjectsForUserPreloader.php.

References $certificates.

50  : 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  }
$certificates
Definition: metarefresh.php:39

◆ preLoad()

ilCertificateObjectsForUserPreloader::preLoad ( int  $userId,
array  $objIds 
)
Parameters
int$userId
int[]$objIds

Definition at line 28 of file class.ilCertificateObjectsForUserPreloader.php.

References $certificates.

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  }
$certificates
Definition: metarefresh.php:39

Field Documentation

◆ $certificates

ilCertificateObjectsForUserPreloader::$certificates = []
staticprivate

◆ $userCertificateRepository

ilCertificateObjectsForUserPreloader::$userCertificateRepository
private

Definition at line 13 of file class.ilCertificateObjectsForUserPreloader.php.

Referenced by __construct().


The documentation for this class was generated from the following file: