本文整理汇总了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);
}
}