1 | <?php |
||
5 | abstract class Worker |
||
6 | { |
||
7 | protected $jobManager; |
||
8 | protected $jobClass; |
||
9 | protected $job; |
||
10 | |||
11 | /** |
||
12 | * @return string |
||
13 | */ |
||
14 | 10 | public function getJobClass() |
|
15 | { |
||
16 | 10 | return $this->jobClass; |
|
17 | } |
||
18 | |||
19 | /** |
||
20 | * @param string $jobClass |
||
21 | */ |
||
22 | 9 | public function setJobClass($jobClass) |
|
23 | { |
||
24 | 9 | $this->jobClass = $jobClass; |
|
25 | 9 | } |
|
26 | |||
27 | /** |
||
28 | * @param JobManagerInterface $jobManager |
||
29 | */ |
||
30 | 19 | public function setJobManager(JobManagerInterface $jobManager) |
|
34 | |||
35 | /** |
||
36 | * @return |
||
37 | */ |
||
38 | 42 | public function getJobManager() |
|
42 | |||
43 | /** |
||
44 | * @param int|null $time |
||
45 | * @param bool $batch |
||
46 | * @param int|null $priority |
||
47 | */ |
||
48 | 14 | public function at($time = null, $batch = false, $priority = null) |
|
49 | { |
||
50 | 14 | if (null === $time) { |
|
51 | $time = time(); |
||
52 | } |
||
53 | |||
54 | 14 | if ($time) { |
|
55 | 14 | $dateTime = new \DateTime(); |
|
56 | 14 | $dateTime->setTimestamp($time); |
|
57 | 14 | } else { |
|
58 | $dateTime = null; |
||
59 | } |
||
60 | |||
61 | 14 | return new $this->jobClass($this, $batch, $priority, $dateTime); |
|
62 | } |
||
63 | |||
64 | /** |
||
65 | * @param int $delay Amount of time to delay |
||
66 | * @param int|null $priority |
||
67 | */ |
||
68 | 11 | public function later($delay = 0, $priority = null) |
|
72 | |||
73 | 12 | public function batchOrLaterDelay($delay = 0, $batch = false, $priority = null) |
|
80 | |||
81 | /** |
||
82 | * @param int $delay Amount of time to delay |
||
83 | * @param int|null $priority |
||
84 | */ |
||
85 | 3 | public function batchLater($delay = 0, $priority = null) |
|
89 | |||
90 | /** |
||
91 | * @param int|null $time |
||
92 | * @param int|null $priority |
||
93 | */ |
||
94 | 1 | public function batchAt($time = null, $priority = null) |
|
98 | |||
99 | abstract public function getName(); |
||
100 | } |
||
101 |