TrackManiaControl/application/libs/FML/Elements/Music.php

64 lines
1.2 KiB
PHP
Raw Normal View History

<?php
namespace FML\Elements;
2014-01-12 00:51:46 +01:00
use FML\Types\Renderable;
/**
2014-01-12 00:51:46 +01:00
* Music Element
*
2014-05-20 15:44:45 +02:00
* @author steeffeen <mail@steeffeen.com>
2014-04-13 18:21:40 +02:00
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
2014-05-18 19:45:50 +02:00
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Music implements Renderable {
2014-01-21 20:30:40 +01:00
/*
2014-06-21 03:18:21 +02:00
* Protected properties
*/
protected $tagName = 'music';
2014-06-21 03:18:21 +02:00
protected $data = null;
2014-01-19 19:30:21 +01:00
/**
2014-06-21 03:18:21 +02:00
* Create a new Music object
2014-01-19 19:30:21 +01:00
*
2014-06-21 03:18:21 +02:00
* @param string $data (optional) Media url
2014-07-03 22:34:47 +02:00
* @return static
2014-01-19 19:30:21 +01:00
*/
public static function create($data = null) {
2014-06-21 03:18:21 +02:00
return new static($data);
2014-01-19 19:30:21 +01:00
}
/**
2014-06-21 03:18:21 +02:00
* Construct a new Music object
2014-01-19 19:30:21 +01:00
*
2014-06-21 03:18:21 +02:00
* @param string $data (optional) Media url
2014-01-19 19:30:21 +01:00
*/
public function __construct($data = null) {
2014-08-11 23:15:53 +02:00
if ($data !== null) {
2014-01-19 19:30:21 +01:00
$this->setData($data);
}
}
/**
2014-06-21 03:18:21 +02:00
* Set data url
*
2014-06-21 03:18:21 +02:00
* @param string $data Data url
2014-07-03 22:34:47 +02:00
* @return static
*/
public function setData($data) {
2014-05-18 19:45:50 +02:00
$this->data = (string)$data;
return $this;
}
/**
2014-07-03 22:34:47 +02:00
* @see \FML\Types\Renderable::render()
*/
public function render(\DOMDocument $domDocument) {
2014-01-12 00:51:46 +01:00
$xmlElement = $domDocument->createElement($this->tagName);
if ($this->data) {
2014-01-12 00:51:46 +01:00
$xmlElement->setAttribute('data', $this->data);
}
2014-01-12 00:51:46 +01:00
return $xmlElement;
}
}