Пример #1
0
 /**
  * Returns a list of all inactive cronjobs
  * 
  * @param none
  * @return array A string of cronjob names which aren't running
  */
 public function getInactiveCronjobs()
 {
     $dql = "SELECT c.cronjob FROM PartKeepr\\CronLogger\\CronLogger c WHERE c.cronjob = :cronjob";
     $dql .= " AND c.lastRunDate > :date";
     $query = PartKeepr::getEM()->createQuery($dql);
     $date = new \DateTime();
     $date->sub(new \DateInterval('P1D'));
     $query->setParameter("date", $date);
     $failedCronjobs = array();
     foreach (PartKeepr::getRequiredCronjobs() as $cronjob) {
         $query->setParameter("cronjob", $cronjob);
         try {
             $query->getSingleResult();
         } catch (\Exception $e) {
             $failedCronjobs[] = $cronjob;
         }
     }
     return $failedCronjobs;
 }
Пример #2
0
 /**
  * Marks the cronjobs as run, so that the user doesn't get an error during the first day.
  * 
  * This is necessary because if the user sets up the system and enters the cronjobs, there is a chance
  * that no cronjob has been ran when he logs in the first time and thus gets confused.
  */
 public function markCronjobsAsRun()
 {
     foreach (PartKeepr::getRequiredCronjobs() as $cronjob) {
         CronLoggerManager::getInstance()->markCronRun($cronjob);
     }
 }