public function DateRecurNonRecurringHelper::generateOccurrences in Recurring Dates Field 3.1.x
Same name and namespace in other branches
- 8.2 src/DateRecurNonRecurringHelper.php \Drupal\date_recur\DateRecurNonRecurringHelper::generateOccurrences()
- 3.x src/DateRecurNonRecurringHelper.php \Drupal\date_recur\DateRecurNonRecurringHelper::generateOccurrences()
- 3.0.x src/DateRecurNonRecurringHelper.php \Drupal\date_recur\DateRecurNonRecurringHelper::generateOccurrences()
Calculates occurrences as a generator.
Parameters
\DateTimeInterface|null $rangeStart: The start of the range, or start with the first available occurrence.
\DateTimeInterface|null $rangeEnd: The end of the range, or never end.
Return value
\Generator|\Drupal\date_recur\DateRange[] A date range generator.
Overrides DateRecurHelperInterface::generateOccurrences
1 call to DateRecurNonRecurringHelper::generateOccurrences()
- DateRecurNonRecurringHelper::getOccurrences in src/
DateRecurNonRecurringHelper.php - Get all occurrences.
File
- src/
DateRecurNonRecurringHelper.php, line 56
Class
- DateRecurNonRecurringHelper
- Dummy helper for handling non-recurring values.
Namespace
Drupal\date_recurCode
public function generateOccurrences(?\DateTimeInterface $rangeStart = NULL, ?\DateTimeInterface $rangeEnd = NULL) : \Generator {
foreach ($this->occurrences as $occurrence) {
$occurrenceStart = $occurrence
->getStart();
$occurrenceEnd = $occurrence
->getEnd();
if ($rangeStart) {
if ($occurrenceStart < $rangeStart && $occurrenceEnd < $rangeStart) {
continue;
}
}
if ($rangeEnd) {
if ($occurrenceStart > $rangeEnd && $occurrenceEnd > $rangeEnd) {
break;
}
}
(yield $occurrence);
}
}