ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
JobEntity.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Cron\Job;
22
24
26{
27 private string $job_id;
28 private string $component;
30 private ?int $raw_schedule_type;
31 private int $schedule_value;
32 private ?int $raw_schedule_value;
33 private int $job_status;
34 private int $job_status_usr_id;
35 private int $job_status_type;
37 private int $job_result_status;
38 private int $job_result_usr_id;
39 private string $job_result_code;
40 private string $job_result_message;
41 private int $job_result_type;
43 private string $class;
44 private string $path;
45 private int $running_timestamp;
47 private int $alive_timestamp;
48
52 public function __construct(
53 private readonly \ILIAS\Cron\CronJob $job,
54 array $record,
55 private readonly bool $isPlugin = false
56 ) {
57 $this->mapRecord($record);
58 }
59
63 private function mapRecord(array $record): void
64 {
65 $this->job_id = (string) $record['job_id'];
66 $this->component = (string) $record['component'];
67 $this->schedule_type = is_numeric($record['schedule_type']) ? JobScheduleType::tryFrom(
68 (int) $record['schedule_type']
69 ) : null;
70 $this->raw_schedule_type = $record['schedule_type'];
71 $this->schedule_value = (int) $record['schedule_value'];
72 $this->raw_schedule_value = $record['schedule_value'];
73 $this->job_status = (int) $record['job_status'];
74 $this->job_status_usr_id = (int) $record['job_status_user_id'];
75 $this->job_status_type = (int) $record['job_status_type'];
76 $this->job_status_timestamp = (int) $record['job_status_ts'];
77 $this->job_result_status = (int) $record['job_result_status'];
78 $this->job_result_usr_id = (int) $record['job_result_user_id'];
79 $this->job_result_code = (string) $record['job_result_code'];
80 $this->job_result_message = (string) $record['job_result_message'];
81 $this->job_result_type = (int) $record['job_result_type'];
82 $this->job_result_timestamp = (int) $record['job_result_ts'];
83 $this->class = (string) $record['class'];
84 $this->path = (string) $record['path'];
85 $this->running_timestamp = (int) $record['running_ts'];
86 $this->job_result_duration = (int) $record['job_result_dur'];
87 $this->alive_timestamp = (int) $record['alive_ts'];
88 }
89
90 public function getJob(): \ILIAS\Cron\CronJob
91 {
92 return $this->job;
93 }
94
95 public function getJobId(): string
96 {
97 return $this->job_id;
98 }
99
100 public function getEffectiveJobId(): string
101 {
102 $job_id = $this->getJobId();
103 if ($this->isPlugin()) {
104 $job_id = 'pl__' . $this->getComponent() . '__' . $job_id;
105 }
106
107 return $job_id;
108 }
109
110 public function getComponent(): string
111 {
112 return $this->component;
113 }
114
116 {
118 }
119
120 public function getRawScheduleType(): ?int
121 {
123 }
124
125 public function getScheduleValue(): int
126 {
128 }
129
130 public function getRawScheduleValue(): ?int
131 {
133 }
134
135 public function getJobStatus(): int
136 {
137 return $this->job_status;
138 }
139
140 public function getJobStatusUsrId(): int
141 {
143 }
144
145 public function getJobStatusType(): int
146 {
148 }
149
150 public function getJobStatusTimestamp(): int
151 {
153 }
154
155 public function getJobResultStatus(): int
156 {
158 }
159
160 public function getJobResultUsrId(): int
161 {
163 }
164
165 public function getJobResultCode(): string
166 {
168 }
169
170 public function getJobResultMessage(): string
171 {
173 }
174
175 public function getJobResultType(): int
176 {
178 }
179
180 public function getJobResultTimestamp(): int
181 {
183 }
184
185 public function getClass(): string
186 {
187 return $this->class;
188 }
189
190 public function getPath(): string
191 {
192 return $this->path;
193 }
194
195 public function getRunningTimestamp(): int
196 {
198 }
199
200 public function getJobResultDuration(): int
201 {
203 }
204
205 public function getAliveTimestamp(): int
206 {
208 }
209
210 public function isPlugin(): bool
211 {
212 return $this->isPlugin;
213 }
214
216 {
217 $type = $this->getScheduleType();
218 if (!$type || !$this->getJob()->hasFlexibleSchedule()) {
219 $type = $this->getJob()->getDefaultScheduleType();
220 }
221
222 return $type;
223 }
224
226 {
227 $type = $this->getScheduleType();
228 $value = $this->getScheduleValue();
229 if (!$type || !$this->getJob()->hasFlexibleSchedule()) {
230 $value = (int) $this->getJob()->getDefaultScheduleValue();
231 }
232
233 return $value;
234 }
235
236 public function getEffectiveTitle(): string
237 {
238 $id = $this->getJobId();
239 if ($this->isPlugin()) {
240 $id = 'pl__' . $this->getComponent() . '__' . $id;
241 }
242
243 $title = $this->getJob()->getTitle();
244 if ($title === '') {
245 $title = $id;
246 }
247
248 return $title;
249 }
250}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(private readonly \ILIAS\Cron\CronJob $job, array $record, private readonly bool $isPlugin=false)
Definition: JobEntity.php:52
mapRecord(array $record)
Definition: JobEntity.php:63
JobScheduleType $schedule_type
Definition: JobEntity.php:29
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.