Timeline.php in Views TimelineJS integration 7.3
File
src/Timeline.php
View source
<?php
class Timeline implements TimelineInterface {
protected $scale = 'human';
protected $title_slide;
protected $events = array();
protected $eras = array();
public function setTitleSlide(\TimelineSlideInterface $slide) {
$this->title_slide = $slide;
}
public function getTitleSlide() {
return $this->title_slide;
}
public function addEvent(\TimelineSlideInterface $slide) {
$this->events[] = $slide;
}
public function getEvents() {
return $this->events;
}
public function addEra(\TimelineEraInterface $era) {
$this->eras[] = $era;
}
public function getEras() {
return $this->eras;
}
public function setScaleToHuman() {
$this->scale = 'human';
}
public function setScaleToCosomological() {
$this->scale = 'cosomological';
}
public function getScale() {
return $this->scale;
}
public function buildArray() {
$timeline = array(
'scale' => $this->scale,
);
if (!empty($this->title_slide)) {
$timeline['title'] = $this->title_slide
->buildArray();
}
foreach ($this->events as $event) {
$timeline['events'][] = $event
->buildArray();
}
foreach ($this->eras as $era) {
$timeline['eras'][] = $era
->buildArray();
}
return $timeline;
}
}