TrackManiaControl/application/core/Libs/FML/Elements/Including.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
* Include Element
*
* @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
*/
class Including implements Renderable {
2014-01-21 20:30:40 +01:00
/*
2013-12-31 02:55:19 +01:00
* Protected Properties
*/
protected $tagName = 'include';
2014-01-12 00:51:46 +01:00
protected $url = '';
2014-01-19 19:30:21 +01:00
/**
* Construct a new Include Element
*
* @param string $url (optional) Include Url
* @return \FML\Elements\Including
*/
public static function create($url = null) {
$including = new Including($url);
return $including;
}
/**
* Construct a new Include Element
*
* @param string $url (optional) Include Url
*/
public function __construct($url = null) {
if ($url !== null) {
$this->setUrl($url);
}
}
/**
2013-12-31 02:55:19 +01:00
* Set Url
*
2014-01-12 00:51:46 +01:00
* @param string $url Include Url
*/
public function setUrl($url) {
2014-01-12 00:51:46 +01:00
$this->url = (string) $url;
}
/**
*
* @see \FML\Renderable::render()
*/
public function render(\DOMDocument $domDocument) {
2014-01-12 00:51:46 +01:00
$xmlElement = $domDocument->createElement($this->tagName);
2013-12-31 02:55:19 +01:00
if ($this->url) {
2014-01-12 00:51:46 +01:00
$xmlElement->setAttribute('url', $this->url);
2013-12-31 02:55:19 +01:00
}
2014-01-12 00:51:46 +01:00
return $xmlElement;
}
}