@@ 226-242 (lines=17) @@ | ||
223 | * |
|
224 | * @param int $when Timestamp to start this job, or null to start immediately |
|
225 | */ |
|
226 | protected function ensurePublishJob($when) |
|
227 | { |
|
228 | // Check if there is a prior job |
|
229 | if ($this->owner->PublishJobID) { |
|
230 | $job = $this->owner->PublishJob(); |
|
231 | // Use timestamp for sake of comparison. |
|
232 | if ($job && $job->exists() && DBDatetime::create()->setValue($job->StartAfter)->getTimestamp() == $when) { |
|
233 | return; |
|
234 | } |
|
235 | $this->clearPublishJob(); |
|
236 | } |
|
237 | ||
238 | // Create a new job with the specified schedule |
|
239 | $job = new WorkflowPublishTargetJob($this->owner, 'publish'); |
|
240 | $this->owner->PublishJobID = Injector::inst()->get(QueuedJobService::class) |
|
241 | ->queueJob($job, $when ? date('Y-m-d H:i:s', $when) : null); |
|
242 | } |
|
243 | ||
244 | /** |
|
245 | * Ensure the existence of an unpublish job at the specified time |
|
@@ 249-265 (lines=17) @@ | ||
246 | * |
|
247 | * @param int $when Timestamp to start this job, or null to start immediately |
|
248 | */ |
|
249 | protected function ensureUnPublishJob($when) |
|
250 | { |
|
251 | // Check if there is a prior job |
|
252 | if ($this->owner->UnPublishJobID) { |
|
253 | $job = $this->owner->UnPublishJob(); |
|
254 | // Use timestamp for sake of comparison. |
|
255 | if ($job && $job->exists() && DBDatetime::create()->setValue($job->StartAfter)->getTimestamp() == $when) { |
|
256 | return; |
|
257 | } |
|
258 | $this->clearUnPublishJob(); |
|
259 | } |
|
260 | ||
261 | // Create a new job with the specified schedule |
|
262 | $job = new WorkflowPublishTargetJob($this->owner, 'unpublish'); |
|
263 | $this->owner->UnPublishJobID = Injector::inst()->get(QueuedJobService::class) |
|
264 | ->queueJob($job, $when ? date('Y-m-d H:i:s', $when) : null); |
|
265 | } |
|
266 | ||
267 | public function onBeforeDuplicate($original, $doWrite) |
|
268 | { |