/** * Call this function to execute jobs which are due to occur now. */ public function run() { $jobs = $this->jobFinder->find(); if (is_null($jobs)) { return; } foreach ($jobs as $job) { // TODO Should jobs be locked prior to running them? $start = date('Y-m-d H:i:s', time()); $executor = new Executor($job); $response = $executor->run(); $finish = date('Y-m-d H:i:s', time()); $this->addJobToHistory($job, $response, $start, $finish); $this->sendNotifications($job, $response, $start, $finish); } }