本文整理匯總了PHP中PartKeepr\PartKeepr::getRequiredCronjobs方法的典型用法代碼示例。如果您正苦於以下問題:PHP PartKeepr::getRequiredCronjobs方法的具體用法?PHP PartKeepr::getRequiredCronjobs怎麽用?PHP PartKeepr::getRequiredCronjobs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PartKeepr\PartKeepr
的用法示例。
在下文中一共展示了PartKeepr::getRequiredCronjobs方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getInactiveCronjobs
/**
* 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: markCronjobsAsRun
/**
* 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);
}
}