ILIAS  release_8 Revision v8.23
ilCertificateQueueRepository Class Reference
+ Collaboration diagram for ilCertificateQueueRepository:

Public Member Functions

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

Private Attributes

ilDBInterface $database
 
ilLogger $logger
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

References $database, $logger, and ILIAS\Repository\logger().

+ Here is the call graph for this function:

Member Function Documentation

◆ addToQueue()

ilCertificateQueueRepository::addToQueue ( ilCertificateQueueEntry  $certificateQueueEntry)

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

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

35  : void
36  {
37  $this->logger->debug('START - Add new entry to certificate cron job queue');
38 
39  $id = $this->database->nextId('il_cert_cron_queue');
40 
41  $row = [
42  'id' => ['integer', $id],
43  'obj_id' => ['integer', $certificateQueueEntry->getObjId()],
44  'usr_id' => ['integer', $certificateQueueEntry->getUserId()],
45  'adapter_class' => ['text', $certificateQueueEntry->getAdapterClass()],
46  'state' => ['text', $certificateQueueEntry->getState()],
47  'started_timestamp' => ['integer', $certificateQueueEntry->getStartedTimestamp()],
48  'template_id' => ['integer', $certificateQueueEntry->getTemplateId()],
49  ];
50 
51  $this->logger->debug(sprintf(
52  'Save queue entry with following values: %s',
53  json_encode($row, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT)
54  ));
55  $this->logger->debug('END - Added entry to queue');
56 
57  $this->database->insert('il_cert_cron_queue', $row);
58  }
$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 74 of file class.ilCertificateQueueRepository.php.

References $query, and ILIAS\Repository\logger().

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

◆ removeFromQueue()

ilCertificateQueueRepository::removeFromQueue ( int  $id)

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

References ILIAS\Repository\logger().

60  : void
61  {
62  $this->logger->debug(sprintf('START - Remove entry(id: "%s") from queue', $id));
63 
64  $sql = 'DELETE FROM il_cert_cron_queue WHERE id = ' . $this->database->quote($id, 'integer');
65 
66  $this->database->manipulate($sql);
67 
68  $this->logger->debug(sprintf('END - Entry(id: "%s") deleted from queue', $id));
69  }
$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 104 of file class.ilCertificateQueueRepository.php.

References ILIAS\Repository\logger().

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

Field Documentation

◆ $database

ilDBInterface ilCertificateQueueRepository::$database
private

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

Referenced by __construct().

◆ $logger

ilLogger ilCertificateQueueRepository::$logger
private

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

Referenced by __construct().


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