1 | <?php |
||
19 | abstract class AbstractQueuedJob implements QueuedJob |
||
20 | { |
||
21 | /** |
||
22 | * @var stdClass |
||
23 | */ |
||
24 | protected $jobData; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | protected $messages = array(); |
||
30 | |||
31 | /** |
||
32 | * @var int |
||
33 | */ |
||
34 | protected $totalSteps = 0; |
||
35 | |||
36 | /** |
||
37 | * @var int |
||
38 | */ |
||
39 | protected $currentStep = 0; |
||
40 | |||
41 | /** |
||
42 | * @var boolean |
||
43 | */ |
||
44 | protected $isComplete = false; |
||
45 | |||
46 | /** |
||
47 | * Extensions can have a construct but don't have too. |
||
48 | * Without a construct, it's impossible to create a job in the CMS |
||
49 | * @var array params |
||
50 | */ |
||
51 | public function __construct($params = array()) |
||
54 | |||
55 | /** |
||
56 | * @return string |
||
57 | */ |
||
58 | abstract public function getTitle(); |
||
59 | |||
60 | /** |
||
61 | * Sets a data object for persisting by adding its id and type to the serialised vars |
||
62 | * |
||
63 | * @param DataObject $object |
||
64 | * @param string $name A name to give it, if you want to store more than one |
||
65 | */ |
||
66 | protected function setObject(DataObject $object, $name = 'SilverStripe\\Core\\Object') |
||
71 | |||
72 | /** |
||
73 | * @param string $name |
||
74 | * @return DataObject|void |
||
75 | */ |
||
76 | protected function getObject($name = 'SilverStripe\\Core\\Object') |
||
84 | |||
85 | /** |
||
86 | * Return a signature for this queued job |
||
87 | * |
||
88 | * @return string |
||
89 | */ |
||
90 | public function getSignature() |
||
94 | |||
95 | /** |
||
96 | * Generate a somewhat random signature |
||
97 | * |
||
98 | * useful if you're want to make sure something is always added |
||
99 | * |
||
100 | * @return string |
||
101 | */ |
||
102 | protected function randomSignature() |
||
106 | |||
107 | /** |
||
108 | * By default jobs should just go into the default processing queue |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | public function getJobType() |
||
116 | |||
117 | /** |
||
118 | * Performs setup tasks the first time this job is run. |
||
119 | * |
||
120 | * This is only executed once for every job. If you want to run something on every job restart, use the |
||
121 | * {@link prepareForRestart} method. |
||
122 | */ |
||
123 | public function setup() |
||
127 | |||
128 | /** |
||
129 | * Run when an already setup job is being restarted. |
||
130 | */ |
||
131 | public function prepareForRestart() |
||
135 | |||
136 | /** |
||
137 | * Do some processing yourself! |
||
138 | */ |
||
139 | abstract public function process(); |
||
140 | |||
141 | /** |
||
142 | * Method for determining whether the job is finished - you may override it if there's |
||
143 | * more to it than just this |
||
144 | */ |
||
145 | public function jobFinished() |
||
149 | |||
150 | /** |
||
151 | * Called when the job is determined to be 'complete' |
||
152 | */ |
||
153 | public function afterComplete() |
||
156 | |||
157 | /** |
||
158 | * @return stdClass |
||
159 | */ |
||
160 | public function getJobData() |
||
179 | |||
180 | /** |
||
181 | * @param int $totalSteps |
||
182 | * @param int $currentStep |
||
183 | * @param boolean $isComplete |
||
184 | * @param stdClass $jobData |
||
185 | * @param array $messages |
||
186 | */ |
||
187 | public function setJobData($totalSteps, $currentStep, $isComplete, $jobData, $messages) |
||
195 | |||
196 | /** |
||
197 | * Gets custom config settings to use when running the job. |
||
198 | * |
||
199 | * @return array|null |
||
200 | */ |
||
201 | public function getCustomConfig() |
||
205 | |||
206 | /** |
||
207 | * Sets custom config settings to use when the job is run. |
||
208 | * |
||
209 | * @param array $config |
||
210 | */ |
||
211 | public function setCustomConfig(array $config) |
||
215 | |||
216 | /** |
||
217 | * Sets custom configuration settings from the job data. |
||
218 | */ |
||
219 | private function loadCustomConfig() |
||
233 | |||
234 | /** |
||
235 | * @param string $message |
||
236 | * @param string $severity |
||
237 | */ |
||
238 | public function addMessage($message, $severity = 'INFO') |
||
243 | |||
244 | /** |
||
245 | * Convenience methods for setting and getting job data |
||
246 | * |
||
247 | * @param mixed $name |
||
248 | * @param mixed $value |
||
249 | */ |
||
250 | public function __set($name, $value) |
||
257 | |||
258 | /** |
||
259 | * Retrieve some job data |
||
260 | * |
||
261 | * @param mixed $name |
||
262 | * @return mixed |
||
263 | */ |
||
264 | public function __get($name) |
||
268 | } |
||
269 |
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.