class Timeline in Views TimelineJS integration 8.3
Defines a TimelineJS3 timeline.
Hierarchy
- class \Drupal\views_timelinejs\TimelineJS\Timeline implements TimelineInterface
Expanded class hierarchy of Timeline
1 file declares its use of Timeline
- TimelineJS.php in src/
Plugin/ views/ style/ TimelineJS.php
File
- src/
TimelineJS/ Timeline.php, line 8
Namespace
Drupal\views_timelinejs\TimelineJSView source
class Timeline implements TimelineInterface {
/**
* The timeline scale.
*
* @var string
*/
protected $scale = 'human';
/**
* The timeline's title slide.
*
* @var \Drupal\views_timelinejs\TimelineJS\SlideInterface
*/
protected $titleSlide;
/**
* The timeline's array of event slides.
*
* @var \Drupal\views_timelinejs\TimelineJS\SlideInterface[]
*/
protected $events = [];
/**
* The timeline's array of eras.
*
* @var \Drupal\views_timelinejs\TimelineJS\EraInterface[]
*/
protected $eras = [];
/**
* {@inheritdoc}
*/
public function setTitleSlide(SlideInterface $slide) {
$this->titleSlide = $slide;
}
/**
* {@inheritdoc}
*/
public function getTitleSlide() {
return $this->titleSlide;
}
/**
* {@inheritdoc}
*/
public function addEvent(SlideInterface $slide) {
$this->events[] = $slide;
}
/**
* {@inheritdoc}
*/
public function getEvents() {
return $this->events;
}
/**
* {@inheritdoc}
*/
public function addEra(EraInterface $era) {
$this->eras[] = $era;
}
/**
* {@inheritdoc}
*/
public function getEras() {
return $this->eras;
}
/**
* {@inheritdoc}
*/
public function setScaleToHuman() {
$this->scale = 'human';
}
/**
* {@inheritdoc}
*/
public function setScaleToCosomological() {
$this->scale = 'cosomological';
}
/**
* {@inheritdoc}
*/
public function getScale() {
return $this->scale;
}
/**
* {@inheritdoc}
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Timeline:: |
protected | property | The timeline's array of eras. | |
Timeline:: |
protected | property | The timeline's array of event slides. | |
Timeline:: |
protected | property | The timeline scale. | |
Timeline:: |
protected | property | The timeline's title slide. | |
Timeline:: |
public | function |
Adds a new era to the timeline's eras array. Overrides TimelineInterface:: |
|
Timeline:: |
public | function |
Adds a new slide to the timeline's events array. Overrides TimelineInterface:: |
|
Timeline:: |
public | function |
Creates an array representing the TimelineJS javascript object. Overrides ObjectInterface:: |
|
Timeline:: |
public | function |
Returns the timeline's array of eras. Overrides TimelineInterface:: |
|
Timeline:: |
public | function |
Returns the timeline's array of event slides. Overrides TimelineInterface:: |
|
Timeline:: |
public | function |
Returns the timeline's scale. Overrides TimelineInterface:: |
|
Timeline:: |
public | function |
Returns the timeline's title slide. Overrides TimelineInterface:: |
|
Timeline:: |
public | function |
Sets the timeline's scale to cosmological. Overrides TimelineInterface:: |
|
Timeline:: |
public | function |
Sets the timeline's scale to human. Overrides TimelineInterface:: |
|
Timeline:: |
public | function |
Sets the timeline's title slide. Overrides TimelineInterface:: |