ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilCronJobEntity.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 {
25  private string $jobId;
26  private string $component;
28  private int $scheduleValue;
29  private int $jobStatus;
30  private int $jobStatusUsrId;
31  private int $jobStatusType;
32  private int $jobStatusTimestamp;
33  private int $jobResultStatus;
34  private int $jobResultUsrId;
35  private string $jobResultCode;
36  private string $jobResultMessage;
37  private int $jobResultType;
38  private int $jobResultTimestamp;
39  private string $class;
40  private string $path;
41  private int $runningTimestamp;
42  private int $jobResultDuration;
43  private int $aliveTimestamp;
44 
51  public function __construct(private readonly ilCronJob $job, array $record, private readonly bool $isPlugin = false)
52  {
53  $this->mapRecord($record);
54  }
55 
59  private function mapRecord(array $record): void
60  {
61  $this->jobId = (string) $record['job_id'];
62  $this->component = (string) $record['component'];
63  $this->scheduleType = is_numeric($record['schedule_type']) ? CronJobScheduleType::tryFrom((int) $record['schedule_type']) : null;
64  $this->scheduleValue = (int) $record['schedule_value'];
65  $this->jobStatus = (int) $record['job_status'];
66  $this->jobStatusUsrId = (int) $record['job_status_user_id'];
67  $this->jobStatusType = (int) $record['job_status_type'];
68  $this->jobStatusTimestamp = (int) $record['job_status_ts'];
69  $this->jobResultStatus = (int) $record['job_result_status'];
70  $this->jobResultUsrId = (int) $record['job_result_user_id'];
71  $this->jobResultCode = (string) $record['job_result_code'];
72  $this->jobResultMessage = (string) $record['job_result_message'];
73  $this->jobResultType = (int) $record['job_result_type'];
74  $this->jobResultTimestamp = (int) $record['job_result_ts'];
75  $this->class = (string) $record['class'];
76  $this->path = (string) $record['path'];
77  $this->runningTimestamp = (int) $record['running_ts'];
78  $this->jobResultDuration = (int) $record['job_result_dur'];
79  $this->aliveTimestamp = (int) $record['alive_ts'];
80  }
81 
82  public function getJob(): ilCronJob
83  {
84  return $this->job;
85  }
86 
87  public function getJobId(): string
88  {
89  return $this->jobId;
90  }
91 
92  public function getComponent(): string
93  {
94  return $this->component;
95  }
96 
98  {
99  return $this->scheduleType;
100  }
101 
102  public function getScheduleValue(): int
103  {
104  return $this->scheduleValue;
105  }
106 
107  public function getJobStatus(): int
108  {
109  return $this->jobStatus;
110  }
111 
112  public function getJobStatusUsrId(): int
113  {
114  return $this->jobStatusUsrId;
115  }
116 
117  public function getJobStatusType(): int
118  {
119  return $this->jobStatusType;
120  }
121 
122  public function getJobStatusTimestamp(): int
123  {
125  }
126 
127  public function getJobResultStatus(): int
128  {
129  return $this->jobResultStatus;
130  }
131 
132  public function getJobResultUsrId(): int
133  {
134  return $this->jobResultUsrId;
135  }
136 
137  public function getJobResultCode(): string
138  {
139  return $this->jobResultCode;
140  }
141 
142  public function getJobResultMessage(): string
143  {
145  }
146 
147  public function getJobResultType(): int
148  {
149  return $this->jobResultType;
150  }
151 
152  public function getJobResultTimestamp(): int
153  {
155  }
156 
157  public function getClass(): string
158  {
159  return $this->class;
160  }
161 
162  public function getPath(): string
163  {
164  return $this->path;
165  }
166 
167  public function getRunningTimestamp(): int
168  {
170  }
171 
172  public function getJobResultDuration(): int
173  {
175  }
176 
177  public function getAliveTimestamp(): int
178  {
179  return $this->aliveTimestamp;
180  }
181 
182  public function isPlugin(): bool
183  {
184  return $this->isPlugin;
185  }
186 
188  {
189  $type = $this->getScheduleType();
190  if (!$type || !$this->getJob()->hasFlexibleSchedule()) {
191  $type = $this->getJob()->getDefaultScheduleType();
192  }
193 
194  return $type;
195  }
196 
197  public function getEffectiveScheduleValue(): int
198  {
199  $type = $this->getScheduleType();
200  $value = $this->getScheduleValue();
201  if (!$type || !$this->getJob()->hasFlexibleSchedule()) {
202  $value = (int) $this->getJob()->getDefaultScheduleValue();
203  }
204 
205  return $value;
206  }
207 
208  public function getEffectiveTitle(): string
209  {
210  $id = $this->getJobId();
211  if ($this->isPlugin()) {
212  $id = 'pl__' . $this->getComponent() . '__' . $id;
213  }
214 
215  $title = $this->getJob()->getTitle();
216  if ($title === '') {
217  $title = $id;
218  }
219 
220  return $title;
221  }
222 }
CronJobScheduleType $scheduleType
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(private readonly ilCronJob $job, array $record, private readonly bool $isPlugin=false)
ilCronJobEntity constructor.
mapRecord(array $record)