You are here

public function Timeline::buildArray in Views TimelineJS integration 8.3

Creates an array representing the TimelineJS javascript object.

Return value

mixed[] The formatted array.

Overrides ObjectInterface::buildArray

File

src/TimelineJS/Timeline.php, line 104

Class

Timeline
Defines a TimelineJS3 timeline.

Namespace

Drupal\views_timelinejs\TimelineJS

Code

public function buildArray() {
  $timeline = [
    'scale' => $this->scale,
  ];
  if (!empty($this->titleSlide)) {
    $timeline['title'] = $this->titleSlide
      ->buildArray();
  }
  foreach ($this->events as $event) {
    $timeline['events'][] = $event
      ->buildArray();
  }
  foreach ($this->eras as $era) {
    $timeline['eras'][] = $era
      ->buildArray();
  }
  return $timeline;
}