SliderPro.php in Slider Pro 8
File
src/Entity/SliderPro.php
View source
<?php
namespace Drupal\slider_pro\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\slider_pro\Entity\SliderProInterface;
class SliderPro extends ConfigEntityBase implements SliderProInterface {
protected $id;
protected $label;
protected $options = [];
public function getOptions() {
return $this->options;
}
public function setOptions(array $options) {
$this->options = $options;
}
public function getOption($name) {
return isset($this->options[$name]) ? $this->options[$name] : NULL;
}
public function hasThumbnails() {
return !empty($this
->getOption('thumbnail_position'));
}
public function hasAutoPlay() {
return !empty($this
->getOption('autoplay'));
}
public function allowFullScreen() {
return !empty($this->options['advanced']['full_screen']);
}
public function toOptionSet() {
$optionset = [
'width' => $this
->getOption('width'),
'visibleSize' => $this
->getOption('visible_size'),
'forceSize' => $this
->getOption('force_size'),
'height' => $this
->getOption('height'),
'orientation' => $this
->getOption('orientation'),
'buttons' => $this
->getOption('buttons') ? TRUE : FALSE,
'fade' => $this
->getOption('transition') ? TRUE : FALSE,
'arrows' => $this
->getOption('arrows') ? TRUE : FALSE,
'centerImage' => $this
->getOption('center_image') ? TRUE : FALSE,
'allowScaleUp' => $this
->getOption('allow_scale_up') ? TRUE : FALSE,
'autoHeight' => $this
->getOption('auto_height') ? TRUE : FALSE,
'startSlide' => (int) $this
->getOption('start_slide'),
'shuffle' => $this
->getOption('shuffle') ? TRUE : FALSE,
'loop' => $this
->getOption('loop') ? TRUE : FALSE,
'autoplay' => $this
->hasAutoPlay() ? TRUE : FALSE,
'slideDistance' => (int) $this
->getOption('slide_distance'),
'keyboard' => $this
->getOption('keyboard') ? TRUE : FALSE,
'fullScreen' => $this
->allowFullScreen() ? TRUE : FALSE,
'updateHash' => $this
->getOption('update_hash') ? TRUE : FALSE,
'waitForLayers' => $this
->getOption('wait_for_layers') ? TRUE : FALSE,
'autoScaleLayers' => $this
->getOption('auto_scale_layers') ? TRUE : FALSE,
];
if ($this
->hasAutoPlay()) {
$optionset['autoplayDelay'] = (int) $this
->getOption('autoplay_delay');
$optionset['autoplayDirection'] = $this
->getOption('autoplay_direction');
$optionset['autoplayOnHover'] = $this
->getOption('autoplay_on_hover');
}
if ($this
->allowFullScreen()) {
$optionset['fadeFullScreen'] = $this
->getOption('fade_full_screen') ? TRUE : FALSE;
}
if ($this
->hasThumbnails()) {
$optionset['thumbnailWidth'] = (int) $this
->getOption('thumbnail_width');
$optionset['thumbnailHeight'] = (int) $this
->getOption('thumbnail_height');
$optionset['thumbnailsPosition'] = $this
->getOption('thumbnail_position');
$optionset['thumbnailPointer'] = $this
->getOption('thumbnail_pointer') ? TRUE : FALSE;
$optionset['thumbnailArrows'] = $this
->getOption('thumbnail_arrows') ? TRUE : FALSE;
if ($optionset['thumbnailArrows']) {
$optionset['fadeThumbnailArrows'] = $this
->getOption('fade_thumbnail_arrows') ? TRUE : FALSE;
}
}
return $optionset;
}
public static function create(array $values = []) {
return parent::create($values);
}
}