ILIAS  trunk Revision v11.0_alpha-2645-g16283d3b3f8
ILIAS\Certificate\API\UserCertificateAPI Class Reference
+ Inheritance diagram for ILIAS\Certificate\API\UserCertificateAPI:
+ Collaboration diagram for ILIAS\Certificate\API\UserCertificateAPI:

Public Member Functions

 __construct (?UserDataRepository $user_data_repository=null, ?ilCertificateTemplateRepository $template_repository=null, ?ilCertificateQueueRepository $queue_repository=null, private readonly ilCertificateTypeClassMap $type_class_map=new ilCertificateTypeClassMap(), ?ilLogger $logger=null, ?ilObjectDataCache $object_data_cache=null,)
 
 getUserCertificateData (UserDataFilter $filter, array $ilCtrlStack=[])
 
 getUserCertificateDataMaxCount (UserDataFilter $filter)
 
 certificateCriteriaMetForGivenTemplate (int $usr_id, ilCertificateTemplate $template)
 
 certificateCriteriaMet (int $usr_id, int $obj_id)
 
 isActiveCertificateTemplateAvailableFor (int $obj_id)
 

Private Member Functions

 processEntry (int $userId, ilCertificateTemplate $template)
 

Private Attributes

readonly UserDataRepository $user_data_repository
 
readonly ilCertificateTemplateRepository $template_repository
 
readonly ilCertificateQueueRepository $queue_repository
 
readonly ilLogger $logger
 
readonly ilObjectDataCache $object_data_cache
 

Detailed Description

Definition at line 42 of file UserCertificateAPI.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Certificate\API\UserCertificateAPI::__construct ( ?UserDataRepository  $user_data_repository = null,
?ilCertificateTemplateRepository  $template_repository = null,
?ilCertificateQueueRepository  $queue_repository = null,
private readonly ilCertificateTypeClassMap  $type_class_map = new ilCertificateTypeClassMap(),
?ilLogger  $logger = null,
?ilObjectDataCache  $object_data_cache = null 
)

Definition at line 50 of file UserCertificateAPI.php.

References $DIC, ILIAS\Certificate\API\UserCertificateAPI\$logger, and ILIAS\Repository\logger().

57  {
58  global $DIC;
59 
60  $this->logger = $logger ?? $DIC->logger()->cert();
61  $this->object_data_cache = $object_data_cache ?? $DIC['ilObjDataCache'];
62  $this->user_data_repository = $user_data_repository ?? new UserDataRepository(
63  $DIC->database(),
64  $DIC->ctrl()
65  );
66  $this->template_repository = $template_repository ?? new ilCertificateTemplateDatabaseRepository(
67  $DIC->database(),
69  );
70  $this->queue_repository = $queue_repository ?? new ilCertificateQueueRepository(
71  $DIC->database(),
73  );
74  }
readonly ilObjectDataCache $object_data_cache
readonly ilCertificateQueueRepository $queue_repository
readonly UserDataRepository $user_data_repository
global $DIC
Definition: shib_login.php:26
readonly ilCertificateTemplateRepository $template_repository
+ Here is the call graph for this function:

Member Function Documentation

◆ certificateCriteriaMet()

ILIAS\Certificate\API\UserCertificateAPI::certificateCriteriaMet ( int  $usr_id,
int  $obj_id 
)
Exceptions
ilCertificateConsumerNotSupported
ilCertificateIssuingObjectNotFound
ilCertificateOwnerNotFound
ilCouldNotFindCertificateTemplate
ilInvalidCertificateException

Implements ILIAS\Certificate\API\UserCertificateApiInterface.

Definition at line 105 of file UserCertificateAPI.php.

References ILIAS\Certificate\API\UserCertificateAPI\certificateCriteriaMetForGivenTemplate().

105  : void
106  {
107  $type = $this->object_data_cache->lookupType($obj_id);
108  if (!$this->type_class_map->typeExistsInMap($type)) {
109  throw new ilCertificateConsumerNotSupported(sprintf(
110  "Oject type '%s' is not supported by the certificate component!",
111  $type
112  ));
113  }
114 
115  $template = $this->template_repository->fetchCurrentlyActiveCertificate($obj_id);
116 
117  $this->certificateCriteriaMetForGivenTemplate($usr_id, $template);
118  }
certificateCriteriaMetForGivenTemplate(int $usr_id, ilCertificateTemplate $template)
+ Here is the call graph for this function:

◆ certificateCriteriaMetForGivenTemplate()

ILIAS\Certificate\API\UserCertificateAPI::certificateCriteriaMetForGivenTemplate ( int  $usr_id,
ilCertificateTemplate  $template 
)
Exceptions
ilCertificateIssuingObjectNotFound
ilCertificateOwnerNotFound
ilInvalidCertificateException

Implements ILIAS\Certificate\API\UserCertificateApiInterface.

Definition at line 86 of file UserCertificateAPI.php.

References ilCertificateTemplate\getId(), ilCertificateTemplate\getObjId(), ilCertificateTemplate\getObjType(), ilCertificateTemplate\isCurrentlyActive(), ILIAS\Repository\logger(), and ILIAS\Certificate\API\UserCertificateAPI\processEntry().

Referenced by ILIAS\Certificate\API\UserCertificateAPI\certificateCriteriaMet().

86  : void
87  {
88  if (!$template->isCurrentlyActive()) {
89  $this->logger->debug(sprintf(
90  'Did not trigger certificate achievement for inactive template: usr_id: %s/obj_id: %s/type: %s/template_id: %s',
91  $usr_id,
92  $template->getObjId(),
93  $template->getObjType(),
94  $template->getId()
95  ));
96  return;
97  }
98 
99  $this->processEntry(
100  $usr_id,
101  $template
102  );
103  }
processEntry(int $userId, ilCertificateTemplate $template)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUserCertificateData()

ILIAS\Certificate\API\UserCertificateAPI::getUserCertificateData ( UserDataFilter  $filter,
array  $ilCtrlStack = [] 
)
Parameters
list<class-string>$ilCtrlStack An array of ilCtrl-enabled GUI class names that are used to create the link, if this is an empty array (default) no link will be generated
Returns
array<int, UserCertificateDto>

Implements ILIAS\Certificate\API\UserCertificateApiInterface.

Definition at line 76 of file UserCertificateAPI.php.

76  : array
77  {
78  return $this->user_data_repository->getUserData($filter, $ilCtrlStack);
79  }

◆ getUserCertificateDataMaxCount()

ILIAS\Certificate\API\UserCertificateAPI::getUserCertificateDataMaxCount ( UserDataFilter  $filter)

Implements ILIAS\Certificate\API\UserCertificateApiInterface.

Definition at line 81 of file UserCertificateAPI.php.

81  : int
82  {
83  return $this->user_data_repository->getUserCertificateDataMaxCount($filter);
84  }

◆ isActiveCertificateTemplateAvailableFor()

ILIAS\Certificate\API\UserCertificateAPI::isActiveCertificateTemplateAvailableFor ( int  $obj_id)

Implements ILIAS\Certificate\API\UserCertificateApiInterface.

Definition at line 120 of file UserCertificateAPI.php.

120  : bool
121  {
122  try {
123  return $this->template_repository->fetchCurrentlyActiveCertificate($obj_id)->isCurrentlyActive();
125  return false;
126  }
127  }

◆ processEntry()

ILIAS\Certificate\API\UserCertificateAPI::processEntry ( int  $userId,
ilCertificateTemplate  $template 
)
private
Exceptions
ilCertificateIssuingObjectNotFound
ilCertificateOwnerNotFound
ilCouldNotFindCertificateTemplate
ilInvalidCertificateException

Definition at line 135 of file UserCertificateAPI.php.

References ilCertificateTemplate\getId(), ilCertificateTemplate\getObjId(), ilCertificateTemplate\getObjType(), ilCronConstants\IN_PROGRESS, and ILIAS\Repository\logger().

Referenced by ILIAS\Certificate\API\UserCertificateAPI\certificateCriteriaMetForGivenTemplate().

138  : void {
139  $this->logger->debug(sprintf(
140  'Trigger persisting certificate achievement for: usr_id: %s/obj_id: %s/type: %s/template_id: %s',
141  $userId,
142  $template->getObjId(),
143  $template->getObjType(),
144  $template->getId()
145  ));
146 
147  $entry = new ilCertificateQueueEntry(
148  $template->getObjId(),
149  $userId,
150  $this->type_class_map->getPlaceHolderClassNameByType($template->getObjType()),
152  $template->getId(),
153  time()
154  );
155 
156  $mode = (new ilSetting('certificate'))->get(
157  'persistent_certificate_mode',
158  'persistent_certificate_mode_cron'
159  );
160  if ($mode === 'persistent_certificate_mode_instant') {
161  $cronjob = new ilCertificateCron();
162  $cronjob->init();
163  $cronjob->processEntry(0, $entry, []);
164  return;
165  }
166 
167  $this->queue_repository->addToQueue($entry);
168  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $logger

readonly ilLogger ILIAS\Certificate\API\UserCertificateAPI::$logger
private

◆ $object_data_cache

readonly ilObjectDataCache ILIAS\Certificate\API\UserCertificateAPI::$object_data_cache
private

Definition at line 48 of file UserCertificateAPI.php.

◆ $queue_repository

readonly ilCertificateQueueRepository ILIAS\Certificate\API\UserCertificateAPI::$queue_repository
private

Definition at line 46 of file UserCertificateAPI.php.

◆ $template_repository

readonly ilCertificateTemplateRepository ILIAS\Certificate\API\UserCertificateAPI::$template_repository
private

Definition at line 45 of file UserCertificateAPI.php.

◆ $user_data_repository

readonly UserDataRepository ILIAS\Certificate\API\UserCertificateAPI::$user_data_repository
private

Definition at line 44 of file UserCertificateAPI.php.


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