ILIAS  trunk Revision v11.0_alpha-1843-g9e1fad99175
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilCertificateQueueRepository Class Reference
+ Collaboration diagram for ilCertificateQueueRepository:

Public Member Functions

 __construct (private readonly ilDBInterface $database, private readonly ilLogger $logger)
 
 addToQueue (ilCertificateQueueEntry $certificateQueueEntry)
 
 removeFromQueue (int $id)
 
 getAllEntriesFromQueue ()
 
 removeFromQueueByUserId (int $user_id)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCertificateQueueRepository::__construct ( private readonly ilDBInterface  $database,
private readonly ilLogger  $logger 
)

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

27  {
28  }

Member Function Documentation

◆ addToQueue()

ilCertificateQueueRepository::addToQueue ( ilCertificateQueueEntry  $certificateQueueEntry)

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

References $id, ilCertificateQueueEntry\getAdapterClass(), ilCertificateQueueEntry\getObjId(), ilCertificateQueueEntry\getStartedTimestamp(), ilCertificateQueueEntry\getState(), ilCertificateQueueEntry\getTemplateId(), ilCertificateQueueEntry\getUserId(), and ILIAS\Repository\logger().

30  : void
31  {
32  $this->logger->debug('START - Add new entry to certificate cron job queue');
33 
34  $id = $this->database->nextId('il_cert_cron_queue');
35 
36  $row = [
37  'id' => ['integer', $id],
38  'obj_id' => ['integer', $certificateQueueEntry->getObjId()],
39  'usr_id' => ['integer', $certificateQueueEntry->getUserId()],
40  'adapter_class' => ['text', $certificateQueueEntry->getAdapterClass()],
41  'state' => ['text', $certificateQueueEntry->getState()],
42  'started_timestamp' => ['integer', $certificateQueueEntry->getStartedTimestamp()],
43  'template_id' => ['integer', $certificateQueueEntry->getTemplateId()],
44  ];
45 
46  $this->logger->debug(sprintf(
47  'Save queue entry with following values: %s',
48  json_encode($row, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT)
49  ));
50  $this->logger->debug('END - Added entry to queue');
51 
52  $this->database->insert('il_cert_cron_queue', $row);
53  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ getAllEntriesFromQueue()

ilCertificateQueueRepository::getAllEntriesFromQueue ( )
Returns
ilCertificateQueueEntry[]

Definition at line 69 of file class.ilCertificateQueueRepository.php.

References ILIAS\Repository\logger().

69  : array
70  {
71  $this->logger->debug('START - Fetch all entries from queue');
72 
73  $sql = 'SELECT * FROM il_cert_cron_queue';
74  $query = $this->database->query($sql);
75 
76  $result = [];
77  while ($row = $this->database->fetchAssoc($query)) {
78  $this->logger->debug(sprintf(
79  'Queue entry found: "%s"',
80  json_encode($row, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT)
81  ));
82 
83  $result[] = new ilCertificateQueueEntry(
84  (int) $row['obj_id'],
85  (int) $row['usr_id'],
86  $row['adapter_class'],
87  $row['state'],
88  (int) $row['template_id'],
89  (int) $row['started_timestamp'],
90  (int) $row['id']
91  );
92  }
93 
94  $this->logger->debug(sprintf('END - All queue entries fetched(Total: "%s")', count($result)));
95 
96  return $result;
97  }
+ Here is the call graph for this function:

◆ removeFromQueue()

ilCertificateQueueRepository::removeFromQueue ( int  $id)

Definition at line 55 of file class.ilCertificateQueueRepository.php.

References ILIAS\Repository\logger().

55  : void
56  {
57  $this->logger->debug(sprintf('START - Remove entry(id: "%s") from queue', $id));
58 
59  $sql = 'DELETE FROM il_cert_cron_queue WHERE id = ' . $this->database->quote($id, 'integer');
60 
61  $this->database->manipulate($sql);
62 
63  $this->logger->debug(sprintf('END - Entry(id: "%s") deleted from queue', $id));
64  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ removeFromQueueByUserId()

ilCertificateQueueRepository::removeFromQueueByUserId ( int  $user_id)

Definition at line 99 of file class.ilCertificateQueueRepository.php.

References ILIAS\Repository\logger().

99  : void
100  {
101  $this->logger->debug(sprintf('START - Remove entries for user (usr_id: "%s") from queue', $user_id));
102 
103  $sql = 'DELETE FROM il_cert_cron_queue WHERE usr_id = ' . $this->database->quote($user_id, 'integer');
104 
105  $this->database->manipulate($sql);
106 
107  $this->logger->debug(sprintf('END - Entries for user (usr_id: "%s") deleted from queue', $user_id));
108  }
+ Here is the call graph for this function:

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