19 declare(strict_types=1);
    50         if ($dic && isset($dic[
'lng'])) {
    52             $language->loadLanguageModule(
'certificate');
    55         $this->
lng = $language;
    60         return $this->
lng->txt(
'cert_cron_task_title');
    65         return $this->
lng->txt(
'cert_cron_task_desc');
    68     public function init(): void
    70         if (null === $this->dic) {
    75         $database = $this->dic->database();
    77         if (null === $this->
logger) {
    78             $this->
logger = $this->dic->logger()->cert();
    81         if (null === $this->cronManager) {
    82             $this->cronManager = $this->dic->cron()->manager();
    85         if (null === $this->queueRepository) {
    89         if (null === $this->templateRepository) {
    93         if (null === $this->userRepository) {
    97         if (null === $this->valueReplacement) {
   101         if (null === $this->objectHelper) {
   117         $currentMode = $this->
settings->get(
'persistent_certificate_mode', 
'persistent_certificate_mode_cron');
   118         if ($currentMode !== 
'persistent_certificate_mode_cron') {
   119             $this->
logger->warning(sprintf(
   120                 'Will not start cron job, because the mode is not set as cron job. Current Mode in settings: "%s"',
   127         $this->
logger->debug(
'START - Begin with cron job to create user certificates from templates');
   129         $entries = $this->queueRepository->getAllEntriesFromQueue();
   134         $succeededGenerations = [];
   135         foreach ($entries as $entry) {
   140                     $succeededGenerations
   145                 $this->
logger->warning($exception->getMessage());
   146                 $this->
logger->warning(
'The user MAY not be able to achieve the certificate based on the adapters settings');
   147                 $this->
logger->warning(
'Due the error, the entry will now be removed from the queue.');
   149                 $this->queueRepository->removeFromQueue($entry->getId());
   153                 $this->
logger->warning($exception->getMessage());
   154                 $this->
logger->warning(
'Due the error, the entry will now be removed from the queue.');
   156                 $this->queueRepository->removeFromQueue($entry->getId());
   162         $result->setStatus($status);
   163         if ($succeededGenerations !== []) {
   165                 'Generated %s certificate(s) in run. Result: %s',
   166                 count($succeededGenerations),
   167                 implode(
' | ', $succeededGenerations)
   169             $this->
logger->info($message);
   172             $result->setMessage(
'0 certificates generated in current run.');
   180         return 'certificate';
   195         return CronJobScheduleType::SCHEDULE_TYPE_IN_MINUTES;
   211         if ($entryCounter > 0 && $entryCounter % 10 === 0) {
   212             $this->cronManager->ping($this->
getId());
   215         $this->
logger->debug(
'Entry found will start of processing the entry');
   219         $this->
logger->debug(
'Adapter class to be executed "' . $class . 
'"');
   221         $placeholderValueObject = 
new $class();
   224                 'The given class ' . $class . 
' must be an instance of ilCertificateCronAdapter and must ' .
   225                 'have an accessible namespace. The composer class map should be reloaded.'   233         $this->
logger->debug(sprintf(
   234             'Fetch certificate template for user id: "%s" and object id: "%s" and template id: "%s"',
   240         $template = $this->templateRepository->fetchTemplate($templateId);
   242         $object = $this->objectHelper->getInstanceByObjId(
$objId, 
false);
   245                 'The given object id: "%s"  could not be referred to an actual object',
   250         $type = $object->getType();
   252         $userObject = $this->objectHelper->getInstanceByObjId($userId, 
false);
   257         $this->
logger->debug(sprintf(
   262         $cert_id = $this->userRepository->requestIdentity();
   263         $certificateContent = $template->getCertificateContent();
   265         $placeholderValues = $placeholderValueObject->getPlaceholderValues($userId, 
$objId);
   266         $placeholderValues[
'CERTIFICATE_ID'] = $cert_id->asString();
   268         $this->
logger->debug(sprintf(
   269             'Values for placeholders: "%s"',
   270             json_encode($placeholderValues, JSON_THROW_ON_ERROR)
   273         $certificateContent = $this->valueReplacement->replace(
   283             $userObject->getFullname(),
   286             json_encode($placeholderValues, JSON_THROW_ON_ERROR),
   288             $template->getVersion(),
   292             $template->getBackgroundImagePath(),
   293             $template->getThumbnailImagePath(),
   294             $template->getBackgroundImageIdentification(),
   295             $template->getThumbnailImageIdentification(),
   299         $persistedUserCertificate = $this->userRepository->save($userCertificate);
   301         $succeededGenerations[] = implode(
'/', [
   306         if ($entry->
getId() !== null) {
   307             $this->queueRepository->removeFromQueue($entry->
getId());
   310         $this->dic->event()->raise(
   311             'components/ILIAS/Certificate',
   313             [
'certificate' => $persistedUserCertificate]
   316         return $succeededGenerations;
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static subStr(string $a_str, int $a_start, ?int $a_length=null)
 
Customizing of pimple-DIC for ILIAS. 
 
const ILIAS_VERSION_NUMERIC
 
final const STATUS_NO_ACTION
 
language()
Get interface to the i18n service. 
 
processEntry(string $class_name, int $obj_id, int $usr_id, \ilCertificateTemplate $template)
 
getDefaultScheduleValue()
 
__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 ?ilCronManager $cronManager=null,)