TimelineSlide.php in Views TimelineJS integration 7.3
File
src/TimelineSlide.php
View source
<?php
class TimelineSlide implements TimelineSlideInterface {
protected $start_date;
protected $end_date;
protected $text;
protected $media;
protected $group;
protected $display_date;
protected $background;
protected $autolink = TRUE;
protected $unique_id;
public function __construct(TimelineDateInterface $start_date, TimelineDateInterface $end_date = NULL, TimelineTextInterface $text = NULL) {
$this->start_date = $start_date;
if (!empty($end_date)) {
$this->end_date = $end_date;
}
if (!empty($text)) {
$this->text = $text;
}
}
public function setMedia(\TimelineMediaInterface $media) {
$this->media = $media;
}
public function setGroup($group) {
$this->group = $group;
}
public function setDisplayDate($display_date) {
$this->display_date = $display_date;
}
public function setBackground(\TimelineBackgroundInterface $backgound) {
$this->background = $backgound;
}
public function setUniqueId($id) {
$this->unique_id = $id;
}
public function enableAutolink() {
$this->autolink = TRUE;
}
public function disableAutolink() {
$this->autolink = FALSE;
}
public function buildArray() {
$slide = array(
'start_date' => $this->start_date
->buildArray(),
);
if (!empty($this->end_date) && $this->start_date != $this->end_date) {
$slide['end_date'] = $this->end_date
->buildArray();
}
if (!empty($this->text)) {
$slide['text'] = $this->text
->buildArray();
}
if (!empty($this->media)) {
$slide['media'] = $this->media
->buildArray();
}
if (!empty($this->group)) {
$slide['group'] = $this->group;
}
if (!empty($this->display_date)) {
$slide['display_date'] = $this->display_date;
}
if (!empty($this->background)) {
$slide['background'] = $this->background
->buildArray();
}
if (!$this->autolink) {
$slide['autolink'] = FALSE;
}
if (!empty($this->unique_id)) {
$slide['unique_id'] = $this->unique_id;
}
return array_filter($slide);
}
}