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