|
@@ 208-224 (lines=17) @@
|
| 205 |
|
* |
| 206 |
|
* @param int $when Timestamp to start this job, or null to start immediately |
| 207 |
|
*/ |
| 208 |
|
protected function ensurePublishJob($when) |
| 209 |
|
{ |
| 210 |
|
// Check if there is a prior job |
| 211 |
|
if ($this->owner->PublishJobID) { |
| 212 |
|
$job = $this->owner->PublishJob(); |
| 213 |
|
// Use timestamp for sake of comparison. |
| 214 |
|
if ($job && $job->exists() && DBDatetime::create()->setValue($job->StartAfter)->getTimestamp() == $when) { |
| 215 |
|
return; |
| 216 |
|
} |
| 217 |
|
$this->clearPublishJob(); |
| 218 |
|
} |
| 219 |
|
|
| 220 |
|
// Create a new job with the specified schedule |
| 221 |
|
$job = new WorkflowPublishTargetJob($this->owner, 'publish'); |
| 222 |
|
$this->owner->PublishJobID = Injector::inst()->get(QueuedJobService::class) |
| 223 |
|
->queueJob($job, $when ? date('Y-m-d H:i:s', $when) : null); |
| 224 |
|
} |
| 225 |
|
|
| 226 |
|
/** |
| 227 |
|
* Ensure the existence of an unpublish job at the specified time |
|
@@ 231-247 (lines=17) @@
|
| 228 |
|
* |
| 229 |
|
* @param int $when Timestamp to start this job, or null to start immediately |
| 230 |
|
*/ |
| 231 |
|
protected function ensureUnPublishJob($when) |
| 232 |
|
{ |
| 233 |
|
// Check if there is a prior job |
| 234 |
|
if ($this->owner->UnPublishJobID) { |
| 235 |
|
$job = $this->owner->UnPublishJob(); |
| 236 |
|
// Use timestamp for sake of comparison. |
| 237 |
|
if ($job && $job->exists() && DBDatetime::create()->setValue($job->StartAfter)->getTimestamp() == $when) { |
| 238 |
|
return; |
| 239 |
|
} |
| 240 |
|
$this->clearUnPublishJob(); |
| 241 |
|
} |
| 242 |
|
|
| 243 |
|
// Create a new job with the specified schedule |
| 244 |
|
$job = new WorkflowPublishTargetJob($this->owner, 'unpublish'); |
| 245 |
|
$this->owner->UnPublishJobID = Injector::inst()->get(QueuedJobService::class) |
| 246 |
|
->queueJob($job, $when ? date('Y-m-d H:i:s', $when) : null); |
| 247 |
|
} |
| 248 |
|
|
| 249 |
|
public function onBeforeDuplicate($original, $doWrite) |
| 250 |
|
{ |