You are here

class Media in Views TimelineJS integration 8.3

Defines a TimelineJS3 media object.

Hierarchy

Expanded class hierarchy of Media

1 file declares its use of Media
TimelineJS.php in src/Plugin/views/style/TimelineJS.php
1 string reference to 'Media'
TimelineJS::buildOptionsForm in src/Plugin/views/style/TimelineJS.php
Provide a form to edit options for this plugin.

File

src/TimelineJS/Media.php, line 8

Namespace

Drupal\views_timelinejs\TimelineJS
View source
class Media implements MediaInterface {

  /**
   * The media url, blockquote, or iframe.
   *
   * @var string
   */
  protected $url;

  /**
   * The media caption.
   *
   * @var string
   */
  protected $caption;

  /**
   * The media credit.
   *
   * @var string
   */
  protected $credit;

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

  /**
   * Constructs a new Media object.
   *
   * @param string $url
   *   The URL of the media resource.
   */
  public function __construct($url) {
    $this->url = $url;
  }

  /**
   * {@inheritdoc}
   */
  public function setCaption($text) {
    $this->caption = $text;
  }

  /**
   * {@inheritdoc}
   */
  public function setCredit($text) {
    $this->credit = $text;
  }

  /**
   * {@inheritdoc}
   */
  public function setThumbnail($url) {
    $this->thumbnail = $url;
  }

  /**
   * {@inheritdoc}
   */
  public function buildArray() {
    $media = [
      'url' => $this->url,
    ];
    if (!empty($this->caption)) {
      $media['caption'] = $this->caption;
    }
    if (!empty($this->credit)) {
      $media['credit'] = $this->credit;
    }
    if (!empty($this->thumbnail)) {
      $media['thumbnail'] = $this->thumbnail;
    }
    return $media;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Media::$caption protected property The media caption.
Media::$credit protected property The media credit.
Media::$thumbnail protected property The media thumbnail image url.
Media::$url protected property The media url, blockquote, or iframe.
Media::buildArray public function Creates an array representing the TimelineJS javascript object. Overrides ObjectInterface::buildArray
Media::setCaption public function Sets the caption for this media. Overrides MediaInterface::setCaption
Media::setCredit public function Sets the credit for this media. Overrides MediaInterface::setCredit
Media::setThumbnail public function Sets the thumbnail image URL for this media. Overrides MediaInterface::setThumbnail
Media::__construct public function Constructs a new Media object.