You are here

protected function TimelineJS::buildEra in Views TimelineJS integration 8.3

Builds a timeline era from the current views data row.

Return value

\Drupal\views_timelinejs\TimelineJS\Era|null An era object or NULL if the start or end date could not be parsed.

1 call to TimelineJS::buildEra()
TimelineJS::render in src/Plugin/views/style/TimelineJS.php
Render the display in this style.

File

src/Plugin/views/style/TimelineJS.php, line 502

Class

TimelineJS
Style plugin to render items as TimelineJS3 slides.

Namespace

Drupal\views_timelinejs\Plugin\views\style

Code

protected function buildEra() {
  $start_date = $this
    ->buildDate($this->options['timeline_fields']['start_date']);

  // Return NULL if the era has no start date.
  if (empty($start_date)) {
    return NULL;
  }
  $end_date = $this
    ->buildDate($this->options['timeline_fields']['end_date']);

  // Return NULL if the era has no end date.
  if (empty($end_date)) {
    return NULL;
  }
  $text = $this
    ->buildText();
  return new Era($start_date, $end_date, $text);
}