public function CronRule::getIntervals in Ultimate Cron 7.2
Same name and namespace in other branches
- 8 CronRule.class.php \CronRule::getIntervals()
- 6 CronRule.class.php \CronRule::getIntervals()
- 7 CronRule.class.php \CronRule::getIntervals()
Generate regex rules.
Return value
array Date and time regular expression for mathing rule.
2 calls to CronRule::getIntervals()
- CronRule::getLastSchedule in ./
CronRule.class.php - Get last schedule time of rule in UNIX timestamp format.
- CronRule::parseRule in ./
CronRule.class.php - Parse rule.
File
- ./
CronRule.class.php, line 189 - This class parses cron rules and determines last execution time using least case integer comparison.
Class
- CronRule
- @file This class parses cron rules and determines last execution time using least case integer comparison.
Code
public function getIntervals() {
if (isset(self::$cache['intervals'][$this->rule][$this->skew])) {
return self::$cache['intervals'][$this->rule][$this->skew];
}
$parts = preg_split('/\\s+/', $this->rule);
if ($this->allow_shorthand) {
// Allow short rules by appending wildcards?
$parts += array(
'*',
'*',
'*',
'*',
'*',
);
$parts = array_slice($parts, 0, 5);
}
if (count($parts) != 5) {
return self::$cache['intervals'][$this->rule][$this->skew] = FALSE;
}
$this
->preProcessRule($parts);
$intervals = array();
$intervals['parts'] = $parts;
$intervals['minutes'] = $this
->expandRange($parts[0], 'minutes');
if (empty($intervals['minutes'])) {
return self::$cache['intervals'][$this->rule][$this->skew] = FALSE;
}
$intervals['hours'] = $this
->expandRange($parts[1], 'hours');
if (empty($intervals['hours'])) {
return self::$cache['intervals'][$this->rule][$this->skew] = FALSE;
}
$intervals['days'] = $this
->expandRange($parts[2], 'days');
if (empty($intervals['days'])) {
return self::$cache['intervals'][$this->rule][$this->skew] = FALSE;
}
$intervals['months'] = $this
->expandRange($parts[3], 'months');
if (empty($intervals['months'])) {
return self::$cache['intervals'][$this->rule][$this->skew] = FALSE;
}
$intervals['weekdays'] = $this
->expandRange($parts[4], 'weekdays');
if (empty($intervals['weekdays'])) {
return self::$cache['intervals'][$this->rule][$this->skew] = FALSE;
}
$intervals['weekdays'] = array_flip($intervals['weekdays']);
$this
->postProcessRule($intervals);
return self::$cache['intervals'][$this->rule][$this->skew] = $intervals;
}