You are here

public function CronRule::getIntervals in Ultimate Cron 8.2

Generate regex rules.

Return value

array Date and time regular expression for mathing rule.

3 calls to CronRule::getIntervals()
CronRule::getLastSchedule in src/CronRule.php
Get last schedule time of rule in UNIX timestamp format.
CronRule::getNextSchedule in src/CronRule.php
Get next schedule time of rule in UNIX timestamp format.
CronRule::parseRule in src/CronRule.php
Parse rule. Run through parser expanding expression, and recombine into crontab syntax.

File

src/CronRule.php, line 201

Class

CronRule

Namespace

Drupal\ultimate_cron

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;
}