ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilCachedCertificateTemplateRepository.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
27 {
29  protected static array $crs_certificates_without_lp = [];
30 
32 
33  public function __construct(ilCertificateTemplateRepository $wrapped)
34  {
35  $this->wrapped = $wrapped;
36  }
37 
38  public function save(ilCertificateTemplate $certificateTemplate): void
39  {
40  $this->wrapped->save($certificateTemplate);
41  }
42 
43  public function updateActivity(ilCertificateTemplate $certificateTemplate, bool $currentlyActive): int
44  {
45  return $this->wrapped->updateActivity($certificateTemplate, $currentlyActive);
46  }
47 
48  public function fetchTemplate(int $templateId): ilCertificateTemplate
49  {
50  return $this->wrapped->fetchTemplate($templateId);
51  }
52 
53  public function fetchCertificateTemplatesByObjId(int $objId): array
54  {
55  return $this->wrapped->fetchCertificateTemplatesByObjId($objId);
56  }
57 
59  {
60  return $this->wrapped->fetchCurrentlyUsedCertificate($objId);
61  }
62 
64  {
65  return $this->wrapped->fetchCurrentlyActiveCertificate($objId);
66  }
67 
69  {
70  return $this->wrapped->fetchPreviousCertificate($objId);
71  }
72 
73  public function deleteTemplate(int $templateId, int $objectId): void
74  {
75  $this->wrapped->deleteTemplate($templateId, $objectId);
76  }
77 
79  {
80  return $this->wrapped->activatePreviousCertificate($objId);
81  }
82 
84  bool $isGlobalLpEnabled,
85  ?int $forRefId = null
86  ): array {
87  $cache_key = (int) $isGlobalLpEnabled . '_' . (int) $forRefId;
88 
89  if (!array_key_exists($cache_key, self::$crs_certificates_without_lp)) {
90  self::$crs_certificates_without_lp[$cache_key] =
91  $this->wrapped->fetchActiveCertificateTemplatesForCoursesWithDisabledLearningProgress(
92  $isGlobalLpEnabled,
93  $forRefId
94  );
95  }
96 
97  return self::$crs_certificates_without_lp[$cache_key];
98  }
99 
101  {
102  return $this->wrapped->fetchFirstCreatedTemplate($objId);
103  }
104 }
A certicate template repository which caches results of query commands List of cached results (other ...
updateActivity(ilCertificateTemplate $certificateTemplate, bool $currentlyActive)
$objId
Definition: xapitoken.php:57
fetchActiveCertificateTemplatesForCoursesWithDisabledLearningProgress(bool $isGlobalLpEnabled, ?int $forRefId=null)