aboutsummaryrefslogtreecommitdiffstats
path: root/core/namespace
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2017-02-27 05:21:42 +0100
committerThomas Lange <code@nerdmind.de>2017-02-27 05:21:42 +0100
commit141f1695a5a8ab1b3bf3cec86749ba2d3fb0e613 (patch)
treed917e461fc5124d7d2fc2ae0936d8aacbf3ce7eb /core/namespace
parentaa71020958cfdff2bdbdf3da0eb0c77acfff7419 (diff)
downloadblog-141f1695a5a8ab1b3bf3cec86749ba2d3fb0e613.tar.gz
blog-141f1695a5a8ab1b3bf3cec86749ba2d3fb0e613.tar.xz
blog-141f1695a5a8ab1b3bf3cec86749ba2d3fb0e613.zip
Unnecessary code removed, comments modified and simple getter method added.
Diffstat (limited to 'core/namespace')
-rw-r--r--core/namespace/Template/Template.php42
1 files changed, 8 insertions, 34 deletions
diff --git a/core/namespace/Template/Template.php b/core/namespace/Template/Template.php
index 158bcd2..1d1f84f 100644
--- a/core/namespace/Template/Template.php
+++ b/core/namespace/Template/Template.php
@@ -6,58 +6,32 @@ class Template {
private $parameters = [];
#===============================================================================
- # Create template instance
+ # Create instance
#===============================================================================
public function __construct($filename) {
$this->filename = $filename;
if(!file_exists($filename)) {
- throw new Exception("Template {$filename} does not exists.");
+ throw new Exception("Template file \"{$filename}\" does not exists.");
}
}
#===============================================================================
- # Set value to array path
+ # Set parameter
#===============================================================================
public function set($name, $value) {
- if(!is_array($name)) {
- return $this->parameters[$name] = $value;
- }
-
- $current = &$this->parameters;
-
- foreach($name as $path) {
- if(!isset($current[$path])) {
- $current[$path] = [];
- }
- $current = &$current[$path];
- }
-
- return $current = $value;
+ return $this->parameters[$name] = $value;
}
#===============================================================================
- # Add value as item to array path
+ # Get parameter
#===============================================================================
- public function add($paths, $value) {
- if(!is_array($paths)) {
- return $this->parameters[$paths][] = $value;
- }
-
- $current = &$this->parameters;
-
- foreach($paths as $path) {
- if(!isset($current[$path])) {
- $current[$path] = [];
- }
- $current = &$current[$path];
- }
-
- return $current[] = $value;
+ public function get($name) {
+ return $this->parameters[$name] ?? NULL;
}
#===============================================================================
- # Return parsed template content
+ # Return HTML
#===============================================================================
public function __toString() {
extract($this->parameters);