Skip to content

Instantly share code, notes, and snippets.

@matrunchyk
Last active May 18, 2016 19:00
Show Gist options
  • Save matrunchyk/4ba322434c8db3b0fddf1219878c5255 to your computer and use it in GitHub Desktop.
Save matrunchyk/4ba322434c8db3b0fddf1219878c5255 to your computer and use it in GitHub Desktop.
ThemeView Decorator
<?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