You are here

protected function DateRecurDefaultFormatter::viewOccurrences in Recurring Dates Field 8

1 call to DateRecurDefaultFormatter::viewOccurrences()
DateRecurDefaultFormatter::viewValue in src/Plugin/Field/FieldFormatter/DateRecurDefaultFormatter.php
Generate the output appropriate for one field item.

File

src/Plugin/Field/FieldFormatter/DateRecurDefaultFormatter.php, line 194

Class

DateRecurDefaultFormatter
Plugin implementation of the 'date_recur_default_formatter' formatter.

Namespace

Drupal\date_recur\Plugin\Field\FieldFormatter

Code

protected function viewOccurrences(DateRecurItem $item) {
  $build = [];
  $start = new \DateTime('now');
  $count = $this
    ->getSetting('show_next');
  if (!$this
    ->getSetting('count_per_item')) {
    $count = $count - $this->occurrenceCounter;
  }
  if ($count <= 0) {
    return $build;
  }
  $occurrences = $item
    ->getOccurrenceHandler()
    ->getOccurrencesForDisplay($start, NULL, $count);
  foreach ($occurrences as $occurrence) {
    if (!empty($occurrence['value'])) {
      $build[] = $this
        ->buildDateRangeValue($occurrence['value'], $occurrence['end_value'], TRUE);
    }
  }
  $this->occurrenceCounter += count($occurrences);
  return $build;
}