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 | 4 | public function __call($method, $args) |
|
23 | { |
||
24 | 4 | $this->method = $method; |
|
25 | 4 | $this->setArgs($args); |
|
26 | |||
27 | // Make sure the method exists - job should not be created |
||
28 | 4 | if (!method_exists($this->worker, $method)) { |
|
29 | throw new \Exception("{$this->className}->{$method}() does not exist"); |
||
30 | } |
||
31 | |||
32 | 4 | $this->jobManager->save($this); |
|
33 | |||
34 | 4 | return $this; |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * @return string|null |
||
39 | */ |
||
40 | public function getMessage() |
||
41 | { |
||
42 | return $this->message; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @param string $message |
||
47 | */ |
||
48 | public function setMessage($message) |
||
49 | { |
||
50 | $this->message = $message; |
||
51 | |||
52 | return $this; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @return bool|null |
||
57 | */ |
||
58 | public function getLocked() |
||
59 | { |
||
60 | return $this->locked; |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @return \DateTime|null |
||
65 | */ |
||
66 | public function getLockedAt() |
||
67 | { |
||
68 | return $this->lockedAt; |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * @return \DateTime|null |
||
73 | */ |
||
74 | 4 | public function getExpiresAt() |
|
78 | |||
79 | /** |
||
80 | * @param bool|null $locked |
||
81 | */ |
||
82 | public function setLocked($locked) |
||
83 | { |
||
84 | $this->locked = $locked; |
||
85 | |||
86 | return $this; |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * @param \DateTime|null $lockedAt |
||
91 | */ |
||
92 | public function setLockedAt($lockedAt) |
||
93 | { |
||
94 | $this->lockedAt = $lockedAt; |
||
95 | |||
96 | return $this; |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * @param \DateTime $expiresAt |
||
101 | */ |
||
102 | public function setExpiresAt(\DateTime $expiresAt) |
||
103 | { |
||
104 | $this->expiresAt = $expiresAt; |
||
105 | |||
106 | return $this; |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * @return int |
||
111 | */ |
||
112 | 4 | public function getId() |
|
116 | |||
117 | /** |
||
118 | * @return string |
||
119 | */ |
||
120 | public function getCrcHash() |
||
121 | { |
||
122 | return $this->crcHash; |
||
123 | } |
||
124 | |||
125 | /** |
||
126 | * @param mixed $id |
||
127 | */ |
||
128 | 4 | public function setId($id) |
|
134 | |||
135 | /** |
||
136 | * @return \DateTime|null |
||
137 | */ |
||
138 | public function getStartedAt() |
||
139 | { |
||
140 | return $this->startedAt; |
||
141 | } |
||
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 | public function getFinishedAt() |
||
157 | { |
||
158 | return $this->finishedAt; |
||
159 | } |
||
160 | |||
161 | /** |
||
162 | * @param \DateTime|null $finishedAt |
||
163 | */ |
||
164 | public function setFinishedAt($finishedAt) |
||
165 | { |
||
166 | $this->finishedAt = $finishedAt; |
||
167 | |||
168 | return $this; |
||
169 | } |
||
170 | |||
171 | /** |
||
172 | * @return int|null |
||
173 | */ |
||
174 | public function getMaxDuration() |
||
175 | { |
||
176 | return $this->maxDuration; |
||
177 | } |
||
178 | |||
179 | /** |
||
180 | * @param int|null $maxDuration |
||
181 | */ |
||
182 | public function setMaxDuration($maxDuration) |
||
183 | { |
||
184 | $this->maxDuration = $maxDuration; |
||
185 | |||
186 | return $this; |
||
187 | } |
||
188 | |||
189 | /** |
||
190 | * @param string $crcHash |
||
191 | */ |
||
192 | public function setCrcHash($crcHash) |
||
193 | { |
||
194 | $this->crcHash = $crcHash; |
||
195 | |||
196 | return $this; |
||
197 | } |
||
198 | |||
199 | /** |
||
200 | * @param JobManagerInterface $jobManager |
||
201 | */ |
||
202 | public function setJobManager(JobManagerInterface $jobManager) |
||
203 | { |
||
204 | $this->jobManager = $jobManager; |
||
205 | |||
206 | return $this; |
||
207 | } |
||
208 | |||
209 | /** |
||
210 | * @return int |
||
211 | */ |
||
212 | 4 | public function getDelay() |
|
216 | |||
217 | /** |
||
218 | * @param int $delay Delay in seconds |
||
219 | */ |
||
220 | public function setDelay($delay) |
||
221 | { |
||
222 | $this->delay = $delay; |
||
223 | |||
224 | return $this; |
||
225 | } |
||
226 | |||
227 | /** |
||
228 | * @return int |
||
229 | */ |
||
230 | public function getElapsed() |
||
231 | { |
||
232 | return $this->elapsed; |
||
233 | } |
||
234 | |||
235 | /** |
||
236 | * @param int $elapsed |
||
237 | */ |
||
238 | public function setElapsed($elapsed) |
||
239 | { |
||
240 | $this->elapsed = $elapsed; |
||
241 | |||
242 | return $this; |
||
243 | } |
||
244 | |||
245 | /** |
||
246 | * @return mixed |
||
247 | */ |
||
248 | public function getRunId() |
||
249 | { |
||
250 | return $this->runId; |
||
251 | } |
||
252 | |||
253 | /** |
||
254 | * @param mixed $runId |
||
255 | */ |
||
256 | 3 | public function setRunId($runId) |
|
262 | } |
||
263 |