Source of file WorkflowPublishTargetJob.php
Size: 1,284 Bytes - Last Modified: 2021-12-24T06:44:28+00:00
/var/www/docs.ssmods.com/process/src/code/jobs/WorkflowPublishTargetJob.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 | <?php /** * A queued job that publishes a target after a delay. * * @package advancedworkflow */ use Symbiote\QueuedJobs\Services\AbstractQueuedJob; class WorkflowPublishTargetJob extends AbstractQueuedJob { public function __construct($obj = null, $type = null) { if ($obj) { $this->setObject($obj); $this->publishType = $type ? strtolower($type) : 'publish'; $this->totalSteps = 1; } } public function getTitle() { return _t( 'AdvancedWorkflowPublishJob.SCHEDULEJOBTITLE', "Scheduled {type} of {object}", "", array( 'type' => $this->publishType, 'object' => $this->getObject()->Title ) ); } public function process() { // Ensures we're retrieving the "draft" version of the object to be published \Versioned::reading_stage('Stage'); if ($target = $this->getObject()) { if ($this->publishType == 'publish') { $target->setIsPublishJobRunning(true); $target->PublishOnDate = ''; $target->writeWithoutVersion(); $target->doPublish(); } else if ($this->publishType == 'unpublish') { $target->setIsPublishJobRunning(true); $target->UnPublishOnDate = ''; $target->writeWithoutVersion(); $target->doUnpublish(); } } $this->currentStep = 1; $this->isComplete = true; } } |