1 | <?php |
||
22 | abstract class AbstractQueuedJob implements QueuedJob |
||
23 | { |
||
24 | /** |
||
25 | * @var stdClass |
||
26 | */ |
||
27 | protected $jobData; |
||
28 | |||
29 | /** |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $messages = array(); |
||
33 | |||
34 | /** |
||
35 | * @var int |
||
36 | */ |
||
37 | protected $totalSteps = 0; |
||
38 | |||
39 | /** |
||
40 | * @var int |
||
41 | */ |
||
42 | protected $currentStep = 0; |
||
43 | |||
44 | /** |
||
45 | * @var boolean |
||
46 | */ |
||
47 | protected $isComplete = false; |
||
48 | |||
49 | /** |
||
50 | * Extensions can have a construct but don't have too. |
||
51 | * Without a construct, it's impossible to create a job in the CMS |
||
52 | * @var array params |
||
53 | */ |
||
54 | public function __construct($params = array()) |
||
57 | |||
58 | /** |
||
59 | * @return string |
||
60 | */ |
||
61 | abstract public function getTitle(); |
||
62 | |||
63 | /** |
||
64 | * Sets a data object for persisting by adding its id and type to the serialised vars |
||
65 | * |
||
66 | * @param DataObject $object |
||
67 | * @param string $name A name to give it, if you want to store more than one |
||
68 | */ |
||
69 | protected function setObject(DataObject $object, $name = 'Object') |
||
74 | |||
75 | /** |
||
76 | * @param string $name |
||
77 | * @return DataObject|null |
||
78 | */ |
||
79 | protected function getObject($name = 'Object') |
||
87 | |||
88 | /** |
||
89 | * Return a signature for this queued job |
||
90 | * |
||
91 | * @return string |
||
92 | */ |
||
93 | public function getSignature() |
||
97 | |||
98 | /** |
||
99 | * Generate a somewhat random signature |
||
100 | * |
||
101 | * useful if you're want to make sure something is always added |
||
102 | * |
||
103 | * @return string |
||
104 | */ |
||
105 | protected function randomSignature() |
||
109 | |||
110 | /** |
||
111 | * By default jobs should just go into the default processing queue |
||
112 | * |
||
113 | * @return string |
||
114 | */ |
||
115 | public function getJobType() |
||
119 | |||
120 | public function getRunAsMemberID() |
||
124 | |||
125 | /** |
||
126 | * Performs setup tasks the first time this job is run. |
||
127 | * |
||
128 | * This is only executed once for every job. If you want to run something on every job restart, use the |
||
129 | * {@link prepareForRestart} method. |
||
130 | */ |
||
131 | public function setup() |
||
135 | |||
136 | /** |
||
137 | * Run when an already setup job is being restarted. |
||
138 | */ |
||
139 | public function prepareForRestart() |
||
143 | |||
144 | /** |
||
145 | * Do some processing yourself! |
||
146 | */ |
||
147 | abstract public function process(); |
||
148 | |||
149 | /** |
||
150 | * Method for determining whether the job is finished - you may override it if there's |
||
151 | * more to it than just this |
||
152 | */ |
||
153 | public function jobFinished() |
||
157 | |||
158 | /** |
||
159 | * Called when the job is determined to be 'complete' |
||
160 | */ |
||
161 | public function afterComplete() |
||
164 | |||
165 | /** |
||
166 | * @return stdClass |
||
167 | */ |
||
168 | public function getJobData() |
||
184 | |||
185 | /** |
||
186 | * @param int $totalSteps |
||
187 | * @param int $currentStep |
||
188 | * @param boolean $isComplete |
||
189 | * @param stdClass $jobData |
||
190 | * @param array $messages |
||
191 | */ |
||
192 | public function setJobData($totalSteps, $currentStep, $isComplete, $jobData, $messages) |
||
200 | |||
201 | /** |
||
202 | * Gets custom config settings to use when running the job. |
||
203 | * |
||
204 | * @return array|null |
||
205 | */ |
||
206 | public function getCustomConfig() |
||
210 | |||
211 | /** |
||
212 | * Sets custom config settings to use when the job is run. |
||
213 | * |
||
214 | * @param array $config |
||
215 | */ |
||
216 | public function setCustomConfig(array $config) |
||
220 | |||
221 | /** |
||
222 | * Sets custom configuration settings from the job data. |
||
223 | */ |
||
224 | private function loadCustomConfig() |
||
238 | |||
239 | /** |
||
240 | * @param string $message |
||
241 | * @param string $severity |
||
242 | */ |
||
243 | public function addMessage($message, $severity = 'INFO') |
||
248 | |||
249 | /** |
||
250 | * Convenience methods for setting and getting job data |
||
251 | * |
||
252 | * @param mixed $name |
||
253 | * @param mixed $value |
||
254 | */ |
||
255 | public function __set($name, $value) |
||
262 | |||
263 | /** |
||
264 | * Retrieve some job data |
||
265 | * |
||
266 | * @param mixed $name |
||
267 | * @return mixed |
||
268 | */ |
||
269 | public function __get($name) |
||
273 | } |
||
274 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.