ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 $schedule_value;
31 private int $job_status;
32 private int $job_status_usr_id;
33 private int $job_status_type;
35 private int $job_result_status;
36 private int $job_result_usr_id;
37 private string $job_result_code;
38 private string $job_result_message;
39 private int $job_result_type;
41 private string $class;
42 private string $path;
43 private int $running_timestamp;
45 private int $alive_timestamp;
46
50 public function __construct(
51 private readonly \ILIAS\Cron\CronJob $job,
52 array $record,
53 private readonly bool $isPlugin = false
54 ) {
55 $this->mapRecord($record);
56 }
57
61 private function mapRecord(array $record): void
62 {
63 $this->job_id = (string) $record['job_id'];
64 $this->component = (string) $record['component'];
65 $this->schedule_type = is_numeric($record['schedule_type']) ? JobScheduleType::tryFrom(
66 (int) $record['schedule_type']
67 ) : null;
68 $this->schedule_value = (int) $record['schedule_value'];
69 $this->job_status = (int) $record['job_status'];
70 $this->job_status_usr_id = (int) $record['job_status_user_id'];
71 $this->job_status_type = (int) $record['job_status_type'];
72 $this->job_status_timestamp = (int) $record['job_status_ts'];
73 $this->job_result_status = (int) $record['job_result_status'];
74 $this->job_result_usr_id = (int) $record['job_result_user_id'];
75 $this->job_result_code = (string) $record['job_result_code'];
76 $this->job_result_message = (string) $record['job_result_message'];
77 $this->job_result_type = (int) $record['job_result_type'];
78 $this->job_result_timestamp = (int) $record['job_result_ts'];
79 $this->class = (string) $record['class'];
80 $this->path = (string) $record['path'];
81 $this->running_timestamp = (int) $record['running_ts'];
82 $this->job_result_duration = (int) $record['job_result_dur'];
83 $this->alive_timestamp = (int) $record['alive_ts'];
84 }
85
86 public function getJob(): \ILIAS\Cron\CronJob
87 {
88 return $this->job;
89 }
90
91 public function getJobId(): string
92 {
93 return $this->job_id;
94 }
95
96 public function getEffectiveJobId(): string
97 {
98 $job_id = $this->getJobId();
99 if ($this->isPlugin()) {
100 $job_id = 'pl__' . $this->getComponent() . '__' . $job_id;
101 }
102
103 return $job_id;
104 }
105
106 public function getComponent(): string
107 {
108 return $this->component;
109 }
110
112 {
114 }
115
116 public function getScheduleValue(): int
117 {
119 }
120
121 public function getJobStatus(): int
122 {
123 return $this->job_status;
124 }
125
126 public function getJobStatusUsrId(): int
127 {
129 }
130
131 public function getJobStatusType(): int
132 {
134 }
135
136 public function getJobStatusTimestamp(): int
137 {
139 }
140
141 public function getJobResultStatus(): int
142 {
144 }
145
146 public function getJobResultUsrId(): int
147 {
149 }
150
151 public function getJobResultCode(): string
152 {
154 }
155
156 public function getJobResultMessage(): string
157 {
159 }
160
161 public function getJobResultType(): int
162 {
164 }
165
166 public function getJobResultTimestamp(): int
167 {
169 }
170
171 public function getClass(): string
172 {
173 return $this->class;
174 }
175
176 public function getPath(): string
177 {
178 return $this->path;
179 }
180
181 public function getRunningTimestamp(): int
182 {
184 }
185
186 public function getJobResultDuration(): int
187 {
189 }
190
191 public function getAliveTimestamp(): int
192 {
194 }
195
196 public function isPlugin(): bool
197 {
198 return $this->isPlugin;
199 }
200
202 {
203 $type = $this->getScheduleType();
204 if (!$type || !$this->getJob()->hasFlexibleSchedule()) {
205 $type = $this->getJob()->getDefaultScheduleType();
206 }
207
208 return $type;
209 }
210
212 {
213 $type = $this->getScheduleType();
214 $value = $this->getScheduleValue();
215 if (!$type || !$this->getJob()->hasFlexibleSchedule()) {
216 $value = (int) $this->getJob()->getDefaultScheduleValue();
217 }
218
219 return $value;
220 }
221
222 public function getEffectiveTitle(): string
223 {
224 $id = $this->getJobId();
225 if ($this->isPlugin()) {
226 $id = 'pl__' . $this->getComponent() . '__' . $id;
227 }
228
229 $title = $this->getJob()->getTitle();
230 if ($title === '') {
231 $title = $id;
232 }
233
234 return $title;
235 }
236}
$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:50
mapRecord(array $record)
Definition: JobEntity.php:61
JobScheduleType $schedule_type
Definition: JobEntity.php:29
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.