/**
  * Creates CronJobDefinition classes from registered schedules
  * 
  */
 public function extractCronJobs()
 {
     $resources = $this->getResource();
     if (empty($resources)) {
         return true;
     }
     foreach ($resources as $name => $resource) {
         $resource["name"] = $name;
         $resource["interval"] = array("days" => $resource["days"], "hours" => $resource["hours"], "minutes" => $resource["minutes"]);
         $resource["weekdays"] = str_split($resource["weekdays"]);
         $this->addCronJob(CronJobDefinition::fromArray($resource, $this));
     }
 }
 protected function extractCronJobs()
 {
     $xml = $this->getXMLResource();
     $crons = $xml->xpath("//Cron");
     $counter = 0;
     foreach ($crons as $cronXML) {
         $counter++;
         $cronDefinition = CronJobDefinition::fromXML($cronXML, $this);
         if (!$cronDefinition) {
             $this->log("Cron nr " . $counter . " is invalid", true);
             continue;
         }
         $this->addCronJob($cronDefinition);
     }
 }
 /**
  * Ćallback for exections, set lastExec to the database
  * @param CronJobDefinition $job
  */
 public function onExecute(CronJobDefinition $job)
 {
     $index = explode("_", $job->getName());
     $jobEntry = $this->getDbResult();
     $jobEntry = $jobEntry[$index[1]];
     $modelName = $this->getModel();
     $model;
     $connection = Doctrine_Manager::getInstance()->getConnection('icinga_web');
     $model = Doctrine_Query::create($connection)->select('*')->from('HmSchedulerEntries h')->where("h.entry_id = ?", $jobEntry["entry_id"])->fetchOne(null, Doctrine_Core::HYDRATE_RECORD);
     if (!$model) {
         $model = new $modelName();
     }
     foreach ($jobEntry as $field => $value) {
         $model->set($field, $value);
     }
     $model->set("lastrun", time());
     $model->save($connection);
 }