ILIAS  release_8 Revision v8.24
ilCertificateCron Class Reference
+ Inheritance diagram for ilCertificateCron:
+ Collaboration diagram for ilCertificateCron:

Public Member Functions

 __construct (?ilCertificateQueueRepository $queueRepository=null, ?ilCertificateTemplateRepository $templateRepository=null, ?ilUserCertificateRepository $userRepository=null, ?ilCertificateValueReplacement $valueReplacement=null, ?ilLogger $logger=null, ?Container $dic=null, ?ilLanguage $language=null, ?ilCertificateObjectHelper $objectHelper=null, ?ilSetting $setting=null, ?ilCronManager $cronManager=null)
 
 getTitle ()
 
 getDescription ()
 
 init ()
 
 run ()
 
 getId ()
 
 hasAutoActivation ()
 Is to be activated on "installation", does only work for ILIAS core cron jobs. More...
 
 hasFlexibleSchedule ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
- Public Member Functions inherited from ilCronJob
 setDateTimeProvider (?Closure $date_time_provider)
 
 isDue (?DateTimeImmutable $last_run, ?int $schedule_type, ?int $schedule_value, bool $is_manually_executed=false)
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule (?int $a_type, ?int $a_value)
 Update current schedule (if flexible) More...
 
 getAllScheduleTypes ()
 Get all available schedule types. More...
 
 getScheduleTypesWithValues ()
 
 getValidScheduleTypes ()
 Returns a collection of all valid schedule types for a specific job. More...
 
 isManuallyExecutable ()
 
 hasCustomSettings ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 
 addToExternalSettingsForm (int $a_form_id, array &$a_fields, bool $a_is_active)
 
 activationWasToggled (ilDBInterface $db, ilSetting $setting, bool $a_currently_active)
 Important: This method is (also) called from the setup process, where the constructor of an ilCronJob ist NOT executed. More...
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 hasAutoActivation ()
 Is to be activated on "installation", does only work for ILIAS core cron jobs. More...
 
 hasFlexibleSchedule ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 run ()
 

Data Fields

const DEFAULT_SCHEDULE_HOURS = 1
 
- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_HOURS = 3
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_DAYS = 4
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_WEEKLY = 5
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_MONTHLY = 6
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_QUARTERLY = 7
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_YEARLY = 8
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 

Protected Attributes

ilLanguage $lng
 
- Protected Attributes inherited from ilCronJob
int $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Private Attributes

ilCertificateQueueRepository $queueRepository
 
ilCertificateTemplateRepository $templateRepository
 
ilUserCertificateRepository $userRepository
 
ilLogger $logger
 
ilCertificateValueReplacement $valueReplacement
 
ilCertificateObjectHelper $objectHelper
 
Container $dic = null
 
ilSetting $settings
 
ilCronManager $cronManager
 

Detailed Description

Author
Niels Theen nthee.nosp@m.n@da.nosp@m.tabay.nosp@m..de

Definition at line 26 of file class.ilCertificateCron.php.

Constructor & Destructor Documentation

◆ __construct()

ilCertificateCron::__construct ( ?ilCertificateQueueRepository  $queueRepository = null,
?ilCertificateTemplateRepository  $templateRepository = null,
?ilUserCertificateRepository  $userRepository = null,
?ilCertificateValueReplacement  $valueReplacement = null,
?ilLogger  $logger = null,
?Container  $dic = null,
?ilLanguage  $language = null,
?ilCertificateObjectHelper  $objectHelper = null,
?ilSetting  $setting = null,
?ilCronManager  $cronManager = null 
)

Definition at line 41 of file class.ilCertificateCron.php.

52 {
53 if (null === $dic) {
54 global $DIC;
55 $dic = $DIC;
56 }
57 $this->dic = $dic;
58
59 $this->queueRepository = $queueRepository;
60 $this->templateRepository = $templateRepository;
61 $this->userRepository = $userRepository;
62 $this->valueReplacement = $valueReplacement;
63 $this->logger = $logger;
64 $this->objectHelper = $objectHelper;
65 $this->settings = $setting;
66 $this->cronManager = $cronManager;
67
68 if ($dic && isset($dic['lng'])) {
69 $language = $dic->language();
70 $language->loadLanguageModule('certificate');
71 }
72
73 $this->lng = $language;
74 }
language()
Get interface to the i18n service.
Definition: Container.php:86
ilCertificateObjectHelper $objectHelper
ilCertificateQueueRepository $queueRepository
ilCertificateTemplateRepository $templateRepository
ilCertificateValueReplacement $valueReplacement
ilUserCertificateRepository $userRepository
global $DIC
Definition: feed.php:28

References $cronManager, $DIC, $dic, $logger, $objectHelper, $queueRepository, $templateRepository, $userRepository, $valueReplacement, ILIAS\DI\Container\language(), ILIAS\Repository\lng(), ILIAS\Repository\logger(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ getDefaultScheduleType()

ilCertificateCron::getDefaultScheduleType ( )

Reimplemented from ilCronJob.

Definition at line 207 of file class.ilCertificateCron.php.

207 : int
208 {
210 }
const SCHEDULE_TYPE_IN_MINUTES
@depracated This will be replaced with an ENUM in ILIAS 9

References ilCronJob\SCHEDULE_TYPE_IN_MINUTES.

◆ getDefaultScheduleValue()

ilCertificateCron::getDefaultScheduleValue ( )

Reimplemented from ilCronJob.

Definition at line 212 of file class.ilCertificateCron.php.

212 : ?int
213 {
214 return 1;
215 }

◆ getDescription()

ilCertificateCron::getDescription ( )

Reimplemented from ilCronJob.

Definition at line 81 of file class.ilCertificateCron.php.

81 : string
82 {
83 return $this->lng->txt('cert_cron_task_desc');
84 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getId()

ilCertificateCron::getId ( )

Reimplemented from ilCronJob.

Definition at line 192 of file class.ilCertificateCron.php.

192 : string
193 {
194 return 'certificate';
195 }

◆ getTitle()

ilCertificateCron::getTitle ( )

Reimplemented from ilCronJob.

Definition at line 76 of file class.ilCertificateCron.php.

76 : string
77 {
78 return $this->lng->txt('cert_cron_task_title');
79 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ hasAutoActivation()

ilCertificateCron::hasAutoActivation ( )

Is to be activated on "installation", does only work for ILIAS core cron jobs.

Reimplemented from ilCronJob.

Definition at line 197 of file class.ilCertificateCron.php.

197 : bool
198 {
199 return true;
200 }

◆ hasFlexibleSchedule()

ilCertificateCron::hasFlexibleSchedule ( )

Reimplemented from ilCronJob.

Definition at line 202 of file class.ilCertificateCron.php.

202 : bool
203 {
204 return true;
205 }

◆ init()

ilCertificateCron::init ( )

Definition at line 86 of file class.ilCertificateCron.php.

86 : void
87 {
88 if (null === $this->dic) {
89 global $DIC;
90 $this->dic = $DIC;
91 }
92
93 $database = $this->dic->database();
94
95 if (null === $this->logger) {
96 $this->logger = $this->dic->logger()->cert();
97 }
98
99 if (null === $this->cronManager) {
100 $this->cronManager = $this->dic->cron()->manager();
101 }
102
103 if (null === $this->queueRepository) {
104 $this->queueRepository = new ilCertificateQueueRepository($database, $this->logger);
105 }
106
107 if (null === $this->templateRepository) {
108 $this->templateRepository = new ilCertificateTemplateDatabaseRepository($database, $this->logger);
109 }
110
111 if (null === $this->userRepository) {
112 $this->userRepository = new ilUserCertificateRepository($database, $this->logger);
113 }
114
115 if (null === $this->valueReplacement) {
116 $this->valueReplacement = new ilCertificateValueReplacement();
117 }
118
119 if (null === $this->objectHelper) {
120 $this->objectHelper = new ilCertificateObjectHelper();
121 }
122
123 if (null === $this->settings) {
124 $this->settings = new ilSetting('certificate');
125 }
126 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $DIC, ILIAS\Repository\logger(), and ILIAS\Repository\settings().

Referenced by run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

ilCertificateCron::run ( )

Reimplemented from ilCronJob.

Definition at line 128 of file class.ilCertificateCron.php.

129 {
130 $this->init();
131
132 $result = new ilCronJobResult();
133 $result->setStatus(ilCronJobResult::STATUS_NO_ACTION);
134
135 $currentMode = $this->settings->get('persistent_certificate_mode', 'persistent_certificate_mode_cron');
136 if ($currentMode !== 'persistent_certificate_mode_cron') {
137 $this->logger->warning(sprintf(
138 'Will not start cron job, because the mode is not set as cron job. Current Mode in settings: "%s"',
139 $currentMode
140 ));
141 return $result;
142 }
143
144 $this->logger->debug('START - Begin with cron job to create user certificates from templates');
145
146 $entries = $this->queueRepository->getAllEntriesFromQueue();
147
149
150 $entryCounter = 0;
151 $succeededGenerations = [];
152 foreach ($entries as $entry) {
153 try {
154 $succeededGenerations = $this->processEntry(
155 $entryCounter,
156 $entry,
157 $succeededGenerations
158 );
159
160 ++$entryCounter;
161 } catch (ilInvalidCertificateException $exception) {
162 $this->logger->warning($exception->getMessage());
163 $this->logger->warning('The user MAY not be able to achieve the certificate based on the adapters settings');
164 $this->logger->warning('Due the error, the entry will now be removed from the queue.');
165
166 $this->queueRepository->removeFromQueue($entry->getId());
167
168 continue;
169 } catch (ilException $exception) {
170 $this->logger->warning($exception->getMessage());
171 $this->logger->warning('Due the error, the entry will now be removed from the queue.');
172
173 $this->queueRepository->removeFromQueue($entry->getId());
174 continue;
175 }
176 }
177
178 $result->setStatus($status);
179 if (count($succeededGenerations) > 0) {
180 $result->setMessage(sprintf(
181 'Generated %s certificate(s) in run. Result: %s',
182 count($succeededGenerations),
183 implode(' | ', $succeededGenerations)
184 ));
185 } else {
186 $result->setMessage('0 certificates generated in current run.');
187 }
188
189 return $result;
190 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References init(), ILIAS\Repository\logger(), ILIAS\Repository\settings(), ilCronJobResult\STATUS_NO_ACTION, and ilCronJobResult\STATUS_OK.

+ Here is the call graph for this function:

Field Documentation

◆ $cronManager

ilCronManager ilCertificateCron::$cronManager
private

Definition at line 39 of file class.ilCertificateCron.php.

Referenced by __construct().

◆ $dic

Container ilCertificateCron::$dic = null
private

Definition at line 37 of file class.ilCertificateCron.php.

Referenced by __construct().

◆ $lng

ilLanguage ilCertificateCron::$lng
protected

Definition at line 30 of file class.ilCertificateCron.php.

◆ $logger

ilLogger ilCertificateCron::$logger
private

Definition at line 34 of file class.ilCertificateCron.php.

Referenced by __construct().

◆ $objectHelper

ilCertificateObjectHelper ilCertificateCron::$objectHelper
private

Definition at line 36 of file class.ilCertificateCron.php.

Referenced by __construct().

◆ $queueRepository

ilCertificateQueueRepository ilCertificateCron::$queueRepository
private

Definition at line 31 of file class.ilCertificateCron.php.

Referenced by __construct().

◆ $settings

ilSetting ilCertificateCron::$settings
private

Definition at line 38 of file class.ilCertificateCron.php.

◆ $templateRepository

ilCertificateTemplateRepository ilCertificateCron::$templateRepository
private

Definition at line 32 of file class.ilCertificateCron.php.

Referenced by __construct().

◆ $userRepository

ilUserCertificateRepository ilCertificateCron::$userRepository
private

Definition at line 33 of file class.ilCertificateCron.php.

Referenced by __construct().

◆ $valueReplacement

ilCertificateValueReplacement ilCertificateCron::$valueReplacement
private

Definition at line 35 of file class.ilCertificateCron.php.

Referenced by __construct().

◆ DEFAULT_SCHEDULE_HOURS

const ilCertificateCron::DEFAULT_SCHEDULE_HOURS = 1

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


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