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