Last active
May 18, 2016 19:00
-
-
Save matrunchyk/4ba322434c8db3b0fddf1219878c5255 to your computer and use it in GitHub Desktop.
ThemeView Decorator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ThemeView | |
{ | |
private $args; | |
private $file; | |
public function __get($name) | |
{ | |
return $this->args[$name]; | |
} | |
public function __construct($file, $args = array()) | |
{ | |
$this->file = 'views/' . $file . '.php'; | |
$this->args = $args; | |
return $this; | |
} | |
public function __isset($name) | |
{ | |
return isset($this->args[$name]); | |
} | |
public function render() | |
{ | |
if (locate_template($this->file)) { | |
include(locate_template($this->file)); | |
} else { | |
throw new ErrorException('Can\'t locate template file: ' . STYLESHEETPATH . '/' . $this->file); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment