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