protected function ensureUnPublishJob($when)
    {
        // Check if there is a prior job
        if ($this->owner->UnPublishJobID) {
            $job = $this->owner->UnPublishJob();
            // Use timestamp for sake of comparison.
            if ($job && $job->exists() && DBDatetime::create()->setValue($job->StartAfter)->getTimestamp() == $when) {
                return;
            }
            $this->clearUnPublishJob();
        }

        // Create a new job with the specified schedule
        $job = new WorkflowPublishTargetJob($this->owner, 'unpublish');
        $this->owner->UnPublishJobID = Injector::inst()->get(QueuedJobService::class)
            ->queueJob($job, $when ? date('Y-m-d H:i:s', $when) : null);
    }
protected function ensureUnPublishJob($when)
    {
        // Check if there is a prior job
        if ($this->owner->UnPublishJobID) {
            $job = $this->owner->UnPublishJob();
            // Use timestamp for sake of comparison.
            if ($job && $job->exists() && DBDatetime::create()->setValue($job->StartAfter)->getTimestamp() == $when) {
                return;
            }
            $this->clearUnPublishJob();
        }

        // Create a new job with the specified schedule
        $job = new WorkflowPublishTargetJob($this->owner, 'unpublish');
        $this->owner->UnPublishJobID = Injector::inst()->get(QueuedJobService::class)
            ->queueJob($job, $when ? date('Y-m-d H:i:s', $when) : null);
    }
protected function ensureUnPublishJob ( $ when ) { // Check if there is a prior job if ( $ this -> owner -> UnPublishJobID ) { $ job = $ this -> owner -> UnPublishJob ( ) ; // Use timestamp for sake of comparison. if ( $ job && $ job -> exists ( ) && DBDatetime :: create ( ) -> setValue ( $ job -> StartAfter ) -> getTimestamp ( ) == $ when ) { return ; } $ this -> clearUnPublishJob ( ) ; } // Create a new job with the specified schedule $ job = new WorkflowPublishTargetJob ( $ this -> owner , 'unpublish' ) ; $ this -> owner -> UnPublishJobID = Injector :: inst ( ) -> get ( QueuedJobService :: class ) -> queueJob ( $ job , $ when ? date ( 'Y-m-d H:i:s' , $ when ) : null ) ; }
Ensure the existence of an unpublish job at the specified time

@param int $when Timestamp to start this job, or null to start immediately
Ensure the existence of an unpublish job at the specified time