You are here

public function RoyalSliderOptionSetEntity::buildJsOptionSet in RoyalSlider Integration 8

Build the javascript array from an optionset.

File

src/Entity/RoyalSliderOptionSetEntity.php, line 665
Contains \Drupal\royalslider\Entity\RoyalSliderOptionSetEntity.

Class

RoyalSliderOptionSetEntity
Defines a RoyalSliderOptionSet configuration entity class.

Namespace

Drupal\royalslider\Entity

Code

public function buildJsOptionSet() {
  $js_array = [
    'autoScaleSlider' => $this->auto_scale_slider,
    'autoScaleSliderWidth' => $this->auto_scale_slider_width,
    'autoScaleSliderHeight' => $this->auto_scale_slider_height,
    'loop' => $this->loop,
  ];

  // Remove the values that are set to the default value.
  foreach ($js_array as $key => $value) {
    if ($this
      ->getOptionDefault($key) == $value) {
      unset($js_array[$key]);
    }
  }
  return $js_array;
}