public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 /**
  * Thells the CronMetaJobProvider that the job is executed and to save it's time
  * 
  * @param String $result Did the job succeed?
  */
 protected function saveLastExec($result)
 {
     $storage = CronJobMetaProvider::getInstance()->getStorage();
     $name = $this->getName();
     $storage[$name] = array("lastExec" => time(), "result" => $result);
     CronJobMetaProvider::getInstance()->setStorage($storage);
     CronJobMetaProvider::getInstance()->saveStorage();
 }
Example #3
0
 /**
  * Executes the scheduler
  */
 public function execute()
 {
     CronJobMetaProvider::getInstance()->processStarted();
     $parser = $this->getParser();
     if (!$parser instanceof CronJobParser) {
         throw new RuntimeException("No parser found!");
     }
     $jobs = $parser->getCronJobs();
     if (!empty($jobs)) {
         foreach ($parser->getCronJobs() as $cron) {
             try {
                 $cron->execute();
             } catch (Exception $e) {
                 $this->log($e->getMessage() . " \n" . $e->getLine() . "\n Trace: \n" . $e->getTrace(), true);
             }
         }
     }
     CronJobMetaProvider::getInstance()->processFinished();
 }