ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilCertificateCron Class Reference
+ Inheritance diagram for ilCertificateCron:
+ Collaboration diagram for ilCertificateCron:

Public Member Functions

 __construct (private ?ilCertificateQueueRepository $queueRepository=null, private ?ilCertificateTemplateRepository $templateRepository=null, private ?ilUserCertificateRepository $userRepository=null, private ?ilCertificateValueReplacement $valueReplacement=null, private ?ilLogger $logger=null, ?Container $dic=null, ?ilLanguage $language=null, private ?ilCertificateObjectHelper $objectHelper=null, private ?ilSetting $settings=null, private ?JobManager $cronManager=null,)
 
 getTitle ()
 
 getDescription ()
 
 init ()
 
 run ()
 
 getId ()
 
 hasAutoActivation ()
 
 hasFlexibleSchedule ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
- Public Member Functions inherited from ILIAS\Cron\CronJob
 setDateTimeProvider (?\Closure $date_time_provider)
 
 isDue (?\DateTimeImmutable $last_run, ?JobScheduleType $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 (?JobScheduleType $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 ()
 
 usesLegacyForms ()
 
 getCustomConfigurationInput (\ILIAS\UI\Factory $ui_factory, \ILIAS\Refinery\Factory $factory, \ilLanguage $lng)
 
 addCustomSettingsToForm (\ilPropertyFormGUI $a_form)
 
 saveCustomConfiguration (mixed $form_data)
 
 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 ()
 

Protected Attributes

ilLanguage $lng
 
- Protected Attributes inherited from ILIAS\Cron\CronJob
JobScheduleType $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Private Attributes

Container $dic
 

Detailed Description

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

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References $DIC, $dic, ILIAS\DI\Container\language(), ILIAS\Repository\lng(), and null.

46  {
47  if (null === $dic) {
48  global $DIC;
49  $dic = $DIC;
50  }
51  $this->dic = $dic;
52 
53  if ($dic && isset($dic['lng'])) {
54  $language = $dic->language();
55  $language->loadLanguageModule('certificate');
56  }
57 
58  $this->lng = $language;
59  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
language()
Get interface to the i18n service.
Definition: Container.php:95
+ Here is the call graph for this function:

Member Function Documentation

◆ getDefaultScheduleType()

ilCertificateCron::getDefaultScheduleType ( )

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

197  {
198  return JobScheduleType::IN_MINUTES;
199  }

◆ getDefaultScheduleValue()

◆ getDescription()

ilCertificateCron::getDescription ( )

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

References ILIAS\Repository\lng().

66  : string
67  {
68  return $this->lng->txt('cert_cron_task_desc');
69  }
+ Here is the call graph for this function:

◆ getId()

ilCertificateCron::getId ( )

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

Referenced by getDefaultScheduleValue().

181  : string
182  {
183  return 'certificate';
184  }
+ Here is the caller graph for this function:

◆ getTitle()

ilCertificateCron::getTitle ( )

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

References ILIAS\Repository\lng().

61  : string
62  {
63  return $this->lng->txt('cert_cron_task_title');
64  }
+ Here is the call graph for this function:

◆ hasAutoActivation()

ilCertificateCron::hasAutoActivation ( )

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

186  : bool
187  {
188  return true;
189  }

◆ hasFlexibleSchedule()

ilCertificateCron::hasFlexibleSchedule ( )

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

191  : bool
192  {
193  return true;
194  }

◆ init()

ilCertificateCron::init ( )

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

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

Referenced by run().

71  : void
72  {
73  if (null === $this->dic) {
74  global $DIC;
75  $this->dic = $DIC;
76  }
77 
78  $database = $this->dic->database();
79 
80  if (null === $this->logger) {
81  $this->logger = $this->dic->logger()->cert();
82  }
83 
84  if (null === $this->cronManager) {
85  $this->cronManager = $this->dic->cron()->manager();
86  }
87 
88  if (null === $this->queueRepository) {
89  $this->queueRepository = new ilCertificateQueueRepository($database, $this->logger);
90  }
91 
92  if (null === $this->templateRepository) {
93  $this->templateRepository = new ilCertificateTemplateDatabaseRepository($database, $this->logger);
94  }
95 
96  if (null === $this->userRepository) {
97  $this->userRepository = new ilUserCertificateRepository($database, $this->logger);
98  }
99 
100  if (null === $this->valueReplacement) {
101  $this->valueReplacement = new ilCertificateValueReplacement();
102  }
103 
104  if (null === $this->objectHelper) {
105  $this->objectHelper = new ilCertificateObjectHelper();
106  }
107 
108  if (null === $this->settings) {
109  $this->settings = new ilSetting('certificate');
110  }
111  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

ilCertificateCron::run ( )

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

References $message, init(), ILIAS\Repository\logger(), processEntry(), ILIAS\Repository\settings(), and ilStr\subStr().

113  : JobResult
114  {
115  $this->init();
116 
117  $result = new JobResult();
118  $result->setStatus(JobResult::STATUS_NO_ACTION);
119 
120  $currentMode = $this->settings->get('persistent_certificate_mode', 'persistent_certificate_mode_cron');
121  if ($currentMode !== 'persistent_certificate_mode_cron') {
122  $this->logger->warning(sprintf(
123  'Will not start cron job, because the mode is not set as cron job. Current Mode in settings: "%s"',
124  $currentMode
125  ));
126 
127  return $result;
128  }
129 
130  $this->logger->debug('START - Begin with cron job to create user certificates from templates');
131 
132  $entries = $this->queueRepository->getAllEntriesFromQueue();
133 
134  $status = JobResult::STATUS_OK;
135 
136  $entryCounter = 0;
137  $succeededGenerations = [];
138  foreach ($entries as $entry) {
139  try {
140  $succeededGenerations = $this->processEntry(
141  $entryCounter,
142  $entry,
143  $succeededGenerations
144  );
145 
146  ++$entryCounter;
147  } catch (ilInvalidCertificateException $exception) {
148  $this->logger->warning($exception->getMessage());
149  $this->logger->warning('The user MAY not be able to achieve the certificate based on the adapters settings');
150  $this->logger->warning('Due the error, the entry will now be removed from the queue.');
151 
152  $this->queueRepository->removeFromQueue($entry->getId());
153 
154  continue;
155  } catch (ilException $exception) {
156  $this->logger->warning($exception->getMessage());
157  $this->logger->warning('Due the error, the entry will now be removed from the queue.');
158 
159  $this->queueRepository->removeFromQueue($entry->getId());
160 
161  continue;
162  }
163  }
164 
165  $result->setStatus($status);
166  if ($succeededGenerations !== []) {
167  $message = sprintf(
168  'Generated %s certificate(s) in run. Result: %s',
169  count($succeededGenerations),
170  implode(' | ', $succeededGenerations)
171  );
172  $this->logger->info($message);
173  $result->setMessage(ilStr::subStr($message, 0, 400));
174  } else {
175  $result->setMessage('0 certificates generated in current run.');
176  }
177 
178  return $result;
179  }
static subStr(string $a_str, int $a_start, ?int $a_length=null)
Definition: class.ilStr.php:24
processEntry(string $class_name, int $obj_id, int $usr_id, \ilCertificateTemplate $template)
$message
Definition: xapiexit.php:31
+ Here is the call graph for this function:

Field Documentation

◆ $dic

Container ilCertificateCron::$dic
private

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

Referenced by __construct().

◆ $lng

ilLanguage ilCertificateCron::$lng
protected

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


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