1 | <?php |
||
7 | 13 | abstract class MessageableJob extends RetryableJob |
|
8 | { |
||
9 | public function __construct(Worker $worker = null, $batch = false, $priority = 10, \DateTime $whenAt = null) |
||
10 | 13 | { |
|
11 | 13 | parent::__construct($worker, $batch, $priority, $whenAt); |
|
12 | 13 | if (!$this->getWhenAt()) { |
|
13 | 13 | $this->setWhenAt(Util::getMicrotimeDateTime()); |
|
14 | } |
||
15 | } |
||
16 | |||
17 | protected function toMessageArray() |
||
18 | { |
||
19 | return array( |
||
20 | 6 | 'worker' => $this->getWorkerName(), |
|
21 | 'args' => $this->getArgs(), |
||
22 | 6 | 'method' => $this->getMethod(), |
|
23 | 'priority' => $this->getPriority(), |
||
24 | 'whenAt' => $this->getWhenAt()->format('U.u'), |
||
25 | 'createdAt' => $this->getCreatedAt()->format('U.u'), |
||
26 | 'updatedAt' => $this->getUpdatedAt()->format('U.u'), |
||
27 | 'expiresAt' => ($expiresAt = $this->getExpiresAt()) ? $expiresAt->format('U.u') : null, |
||
28 | 5 | 'retries' => $this->getRetries(), |
|
29 | 'maxRetries' => $this->getMaxRetries(), |
||
30 | 5 | 'failures' => $this->getFailures(), |
|
31 | 5 | 'maxFailures' => $this->getMaxFailures(), |
|
32 | 5 | 'exceptions' => $this->getExceptions(), |
|
33 | 'maxExceptions' => $this->getMaxExceptions(), |
||
34 | 5 | ); |
|
35 | } |
||
36 | 12 | ||
37 | /** |
||
38 | 12 | * @return string A json_encoded version of a queueable version of the object |
|
39 | 12 | */ |
|
40 | public function toMessage() |
||
44 | 12 | ||
45 | 12 | /** |
|
46 | * @param string $message a json_encoded version of the object |
||
47 | 12 | */ |
|
48 | 3 | public function fromMessage($message) |
|
55 | |||
56 | 12 | protected function fromMessageArray(array $arr) |
|
57 | { |
||
85 | |||
86 | protected function fromMessagearrayRetries(array $arr) |
||
107 | } |
||
108 |