TrackManiaControl/application/core/Libs/FML/ManiaCode/InstallPack.php

100 lines
2.3 KiB
PHP
Raw Normal View History

2014-01-12 00:51:46 +01:00
<?php
namespace FML\ManiaCode;
/**
* ManiaCode Element installing a Title Pack
*
2014-05-18 19:45:50 +02:00
* @author steeffeen
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
2014-01-12 00:51:46 +01:00
*/
class InstallPack implements Element {
2014-01-21 20:30:40 +01:00
/*
2014-01-12 00:51:46 +01:00
* Protected Properties
*/
protected $tagName = 'install_pack';
protected $name = '';
protected $file = '';
protected $url = '';
2014-01-19 19:30:21 +01:00
/**
* Create a new InstallPack Element
*
* @param string $name (optional) Pack Name
* @param string $file (optional) Pack File
2014-05-18 19:45:50 +02:00
* @param string $url (optional) Pack Url
2014-01-19 19:30:21 +01:00
* @return \FML\ManiaCode\InstallPack
*/
public static function create($name = null, $file = null, $url = null) {
$installPack = new InstallPack($name, $file, $url);
return $installPack;
}
2014-01-12 00:51:46 +01:00
/**
* Construct a new InstallPack Element
*
* @param string $name (optional) Pack Name
* @param string $file (optional) Pack File
2014-05-18 19:45:50 +02:00
* @param string $url (optional) Pack Url
2014-01-12 00:51:46 +01:00
*/
public function __construct($name = null, $file = null, $url = null) {
if ($name !== null) {
$this->setName($name);
}
if ($file !== null) {
$this->setFile($file);
}
if ($url !== null) {
$this->setUrl($url);
}
}
/**
2014-04-15 15:47:57 +02:00
* Set the Name of the Pack
2014-01-12 00:51:46 +01:00
*
* @param string $name Pack Name
* @return \FML\ManiaCode\InstallPack
2014-01-19 19:30:21 +01:00
*/
2014-01-12 00:51:46 +01:00
public function setName($name) {
2014-05-18 19:45:50 +02:00
$this->name = (string)$name;
2014-01-12 00:51:46 +01:00
return $this;
}
/**
2014-04-15 15:47:57 +02:00
* Set the File of the Pack
2014-01-12 00:51:46 +01:00
*
* @param string $file Pack File
* @return \FML\ManiaCode\InstallPack
*/
public function setFile($file) {
2014-05-18 19:45:50 +02:00
$this->file = (string)$file;
2014-01-12 00:51:46 +01:00
return $this;
}
/**
2014-04-15 15:47:57 +02:00
* Set the Url of the Pack
2014-01-12 00:51:46 +01:00
*
* @param string $url Pack Url
* @return \FML\ManiaCode\InstallPack
*/
public function setUrl($url) {
2014-05-18 19:45:50 +02:00
$this->url = (string)$url;
2014-01-12 00:51:46 +01:00
return $this;
}
/**
* @see \FML\ManiaCode\Element::render()
*/
public function render(\DOMDocument $domDocument) {
2014-05-18 19:45:50 +02:00
$xmlElement = $domDocument->createElement($this->tagName);
2014-01-12 00:51:46 +01:00
$nameElement = $domDocument->createElement('name', $this->name);
$xmlElement->appendChild($nameElement);
$fileElement = $domDocument->createElement('file', $this->file);
$xmlElement->appendChild($fileElement);
$urlElement = $domDocument->createElement('url', $this->url);
$xmlElement->appendChild($urlElement);
return $xmlElement;
}
}