/** * 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; }
/** * 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); } }