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
|
|
|
* Include Element
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
2014-05-20 15:44:45 +02:00
|
|
|
* @author steeffeen <mail@steeffeen.com>
|
2017-03-25 18:40:15 +01:00
|
|
|
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
|
2014-05-18 19:45:50 +02:00
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
2013-11-25 00:02:07 +01:00
|
|
|
*/
|
2017-03-25 18:40:15 +01:00
|
|
|
class Including implements Renderable
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string $url Include url
|
|
|
|
*/
|
|
|
|
protected $url = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new Include
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
* @param string $url (optional) Include url
|
|
|
|
* @return static
|
|
|
|
*/
|
|
|
|
public static function create($url = null)
|
|
|
|
{
|
|
|
|
return new static($url);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Construct a new Include
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
* @param string $url (optional) Include url
|
|
|
|
*/
|
|
|
|
public function __construct($url = null)
|
|
|
|
{
|
|
|
|
if ($url) {
|
|
|
|
$this->setUrl($url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the url
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getUrl()
|
|
|
|
{
|
|
|
|
return $this->url;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the url
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
* @param string $url Include url
|
|
|
|
* @return static
|
|
|
|
*/
|
|
|
|
public function setUrl($url)
|
|
|
|
{
|
|
|
|
$this->url = (string)$url;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see Renderable::render()
|
|
|
|
*/
|
|
|
|
public function render(\DOMDocument $domDocument)
|
|
|
|
{
|
|
|
|
$domElement = $domDocument->createElement("include");
|
|
|
|
if ($this->url) {
|
|
|
|
$domElement->setAttribute("url", $this->url);
|
|
|
|
}
|
|
|
|
return $domElement;
|
|
|
|
}
|
|
|
|
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|