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