1 | <?php |
||
5 | class Job extends BaseJob |
||
6 | { |
||
7 | const STATUS_EXPIRED = 'expired'; |
||
8 | |||
9 | protected $id; |
||
10 | protected $message; |
||
11 | protected $crcHash; |
||
12 | protected $locked; |
||
13 | protected $lockedAt; |
||
14 | protected $expiresAt; |
||
15 | protected $delay; |
||
16 | protected $startedAt; |
||
17 | protected $finishedAt; |
||
18 | protected $maxDuration; |
||
19 | protected $elapsed; |
||
20 | protected $runId; |
||
21 | |||
22 | 6 | public function __call($method, $args) |
|
23 | { |
||
24 | 6 | $this->method = $method; |
|
25 | 6 | $this->setArgs($args); |
|
26 | |||
27 | // Make sure the method exists - job should not be created |
||
28 | 6 | if (!method_exists($this->worker, $method)) { |
|
29 | throw new \BadMethodCallException("{$this->className}->{$method}() does not exist"); |
||
30 | } |
||
31 | |||
32 | 6 | $job = $this->jobManager->save($this); |
|
33 | |||
34 | 6 | return $job; |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * @return string|null |
||
39 | */ |
||
40 | 2 | public function getMessage() |
|
41 | { |
||
42 | 2 | return $this->message; |
|
43 | } |
||
44 | |||
45 | /** |
||
46 | * @param string $message |
||
47 | */ |
||
48 | 1 | public function setMessage($message) |
|
49 | { |
||
50 | 1 | $this->message = $message; |
|
51 | |||
52 | 1 | return $this; |
|
53 | } |
||
54 | |||
55 | /** |
||
56 | * @return bool|null |
||
57 | */ |
||
58 | 2 | public function getLocked() |
|
62 | |||
63 | /** |
||
64 | * @return \DateTime|null |
||
65 | */ |
||
66 | 2 | public function getLockedAt() |
|
70 | |||
71 | /** |
||
72 | * @return \DateTime|null |
||
73 | */ |
||
74 | 6 | public function getExpiresAt() |
|
78 | |||
79 | /** |
||
80 | * @param bool|null $locked |
||
81 | */ |
||
82 | 2 | public function setLocked($locked) |
|
88 | |||
89 | /** |
||
90 | * @param \DateTime|null $lockedAt |
||
91 | */ |
||
92 | 1 | public function setLockedAt($lockedAt) |
|
98 | |||
99 | /** |
||
100 | * @param \DateTime $expiresAt |
||
101 | */ |
||
102 | 2 | public function setExpiresAt(\DateTime $expiresAt) |
|
108 | |||
109 | /** |
||
110 | * @return int |
||
111 | */ |
||
112 | 6 | public function getId() |
|
116 | |||
117 | /** |
||
118 | * @return string |
||
119 | */ |
||
120 | 2 | public function getCrcHash() |
|
124 | |||
125 | /** |
||
126 | * @param mixed $id |
||
127 | */ |
||
128 | 6 | public function setId($id) |
|
134 | |||
135 | /** |
||
136 | * @return \DateTime|null |
||
137 | */ |
||
138 | 1 | public function getStartedAt() |
|
142 | |||
143 | /** |
||
144 | * @param \DateTime|null $startedAt |
||
145 | */ |
||
146 | public function setStartedAt(\DateTime $startedAt = null) |
||
147 | { |
||
148 | $this->startedAt = $startedAt; |
||
149 | |||
150 | return $this; |
||
151 | } |
||
152 | |||
153 | /** |
||
154 | * @return \DateTime|null |
||
155 | */ |
||
156 | 2 | public function getFinishedAt() |
|
160 | |||
161 | /** |
||
162 | * @param \DateTime|null $finishedAt |
||
163 | */ |
||
164 | 1 | public function setFinishedAt($finishedAt) |
|
170 | |||
171 | /** |
||
172 | * @return int|null |
||
173 | */ |
||
174 | 2 | public function getMaxDuration() |
|
178 | |||
179 | /** |
||
180 | * @param int|null $maxDuration |
||
181 | */ |
||
182 | 1 | public function setMaxDuration($maxDuration) |
|
188 | |||
189 | /** |
||
190 | * @param string $crcHash |
||
191 | */ |
||
192 | 3 | public function setCrcHash($crcHash) |
|
198 | |||
199 | /** |
||
200 | * @param JobManagerInterface $jobManager |
||
201 | */ |
||
202 | 1 | public function setJobManager(JobManagerInterface $jobManager) |
|
208 | |||
209 | /** |
||
210 | * @return int |
||
211 | */ |
||
212 | 6 | public function getDelay() |
|
216 | |||
217 | /** |
||
218 | * @param int $delay Delay in seconds |
||
219 | */ |
||
220 | 4 | public function setDelay($delay) |
|
226 | |||
227 | /** |
||
228 | * @return int |
||
229 | */ |
||
230 | 2 | public function getElapsed() |
|
234 | |||
235 | /** |
||
236 | * @param int $elapsed |
||
237 | */ |
||
238 | 1 | public function setElapsed($elapsed) |
|
244 | |||
245 | /** |
||
246 | * @return mixed |
||
247 | */ |
||
248 | 2 | public function getRunId() |
|
252 | |||
253 | /** |
||
254 | * @param mixed $runId |
||
255 | */ |
||
256 | 4 | public function setRunId($runId) |
|
262 | } |
||
263 |