You are here

class Background in Views TimelineJS integration 8.3

Defines a TimelineJS3 background object.

Hierarchy

Expanded class hierarchy of Background

1 file declares its use of Background
TimelineJS.php in src/Plugin/views/style/TimelineJS.php

File

src/TimelineJS/Background.php, line 8

Namespace

Drupal\views_timelinejs\TimelineJS
View source
class Background implements BackgroundInterface {

  /**
   * The background image url.
   *
   * @var string
   */
  protected $url;

  /**
   * The background color.
   *
   * A CSS color, in hexadecimal (e.g. #0f9bd1) or a valid CSS color keyword.
   *
   * @var string
   */
  protected $color;

  /**
   * Constructs a new Background object.
   *
   * @param string $url
   *   The background image URL.
   * @param string $color
   *   The background color.
   */
  public function __construct($url = '', $color = '') {
    $this->url = $url;
    $this->color = $color;
  }

  /**
   * {@inheritdoc}
   */
  public function buildArray() {
    $background = [];
    if (!empty($this->url)) {
      $background['url'] = $this->url;
    }
    if (!empty($this->color)) {
      $background['color'] = $this->color;
    }
    return $background;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Background::$color protected property The background color.
Background::$url protected property The background image url.
Background::buildArray public function Creates an array representing the TimelineJS javascript object. Overrides ObjectInterface::buildArray
Background::__construct public function Constructs a new Background object.