コード例 #1
0
 /**
  * Gets all of the jobs scheduled to run, now.
  *
  * @return array array(model => CronJob)
  */
 public function getScheduledJobs()
 {
     $jobs = [];
     foreach ($this->jobs as $job) {
         // DEPRECATED this is kept for BC
         if (!isset($job['id'])) {
             $job['id'] = $job['module'] . '.' . $job['command'];
         }
         $model = new CronJob($job['id']);
         // create a new model if this is the job's first run
         if (!$model->exists()) {
             $model = new CronJob();
             $model->id = $job['id'];
             // DEPRECATED this is kept for BC
             if (isset($job['module'])) {
                 $model->module = $job['module'];
             }
             // DEPRECATED this is kept for BC
             if (isset($job['command'])) {
                 $model->command = $job['command'];
             }
         }
         // check if scheduled to run
         $params = new DateParameters($job);
         $date = new CronDate($params, $model->last_ran);
         if ($date->getNextRun() > time()) {
             continue;
         }
         $job = array_replace(['successUrl' => '', 'expires' => 0], $job);
         $job['model'] = $model;
         $jobs[] = $job;
     }
     return $jobs;
 }
コード例 #2
0
 /**
  * Saves the run attempt.
  *
  * @param Run $run
  */
 private function saveRun(Run $run)
 {
     $this->jobModel->last_ran = time();
     $this->jobModel->last_run_succeeded = $run->succeeded();
     $this->jobModel->last_run_output = $run->getOutput();
     $this->jobModel->save();
 }