You are here

protected function DateRecurRRule::createOccurrences in Recurring Dates Field 8

Parameters

null|\DateTime $start:

null|\DateTime $end:

null|int $num:

Return value

array

2 calls to DateRecurRRule::createOccurrences()
DateRecurRRule::getOccurrences in src/DateRecurRRule.php
Get occurrences, optionally limited by a start date, end date and count.
DateRecurRRule::getOccurrencesForCacheStorage in src/DateRecurRRule.php
Get the occurrences for storage in the cache table (for views).

File

src/DateRecurRRule.php, line 272

Class

DateRecurRRule

Namespace

Drupal\date_recur

Code

protected function createOccurrences($start = NULL, $end = NULL, $num = NULL, $display = TRUE) {
  if ($this->rrule
    ->isInfinite() && $end === NULL && $num === NULL) {
    throw new \LogicException('Cannot get all occurrences of an infinite recurrence rule.');
  }
  $occurrences = [];
  foreach ($this->rrule as $occurrence) {
    if ($start !== NULL && $occurrence < $start) {
      continue;
    }
    if ($end !== NULL && $occurrence > $end) {
      break;
    }
    if ($num !== NULL && count($occurrences) >= $num) {
      break;
    }
    $occurrences[] = $this
      ->massageOccurrence($occurrence, $display);
  }
  return $occurrences;
}