@@ 183-198 (lines=16) @@ | ||
180 | * |
|
181 | * @param int $when Timestamp to start this job, or null to start immediately |
|
182 | */ |
|
183 | protected function ensurePublishJob($when) { |
|
184 | // Check if there is a prior job |
|
185 | if($this->owner->PublishJobID) { |
|
186 | $job = $this->owner->PublishJob(); |
|
187 | // Use timestamp for sake of comparison. |
|
188 | if($job && $job->exists() && strtotime($job->StartAfter) == $when) { |
|
189 | return; |
|
190 | } |
|
191 | $this->clearPublishJob(); |
|
192 | } |
|
193 | ||
194 | // Create a new job with the specified schedule |
|
195 | $job = new WorkflowPublishTargetJob($this->owner, 'publish'); |
|
196 | $this->owner->PublishJobID = Injector::inst()->get('QueuedJobService') |
|
197 | ->queueJob($job, $when ? date('Y-m-d H:i:s', $when) : null); |
|
198 | } |
|
199 | ||
200 | /** |
|
201 | * Ensure the existence of an unpublish job at the specified time |
|
@@ 205-220 (lines=16) @@ | ||
202 | * |
|
203 | * @param int $when Timestamp to start this job, or null to start immediately |
|
204 | */ |
|
205 | protected function ensureUnPublishJob($when) { |
|
206 | // Check if there is a prior job |
|
207 | if($this->owner->UnPublishJobID) { |
|
208 | $job = $this->owner->UnPublishJob(); |
|
209 | // Use timestamp for sake of comparison. |
|
210 | if($job && $job->exists() && strtotime($job->StartAfter) == $when) { |
|
211 | return; |
|
212 | } |
|
213 | $this->clearUnPublishJob(); |
|
214 | } |
|
215 | ||
216 | // Create a new job with the specified schedule |
|
217 | $job = new WorkflowPublishTargetJob($this->owner, 'unpublish'); |
|
218 | $this->owner->UnPublishJobID = Injector::inst()->get('QueuedJobService') |
|
219 | ->queueJob($job, $when ? date('Y-m-d H:i:s', $when) : null); |
|
220 | } |
|
221 | ||
222 | /** |
|
223 | * {@see PublishItemWorkflowAction} for approval of requested publish dates |