Skip to content

Commit

Permalink
Fix issue with global variables not being available
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundask committed Mar 17, 2012
1 parent c1b82ad commit dd99efb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion libraries/Twiggy.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Twiggy
private $_config = array();
private $_template_locations = array();
private $_data = array();
private $_globals = array();
private $_themes_base_dir;
private $_theme;
private $_layout;
Expand Down Expand Up @@ -105,6 +106,7 @@ public function set($key, $value, $global = FALSE)
if($global)
{
$this->_twig->addGlobal($key, $value);
$this->_globals[$key] = $value;
}
else
{
Expand Down Expand Up @@ -344,7 +346,16 @@ public function __get($variable)
{
if($variable == 'twig') return $this->_twig;

return (array_key_exists($variable, $this->_data)) ? $this->_data[$variable] : FALSE;
if(array_key_exists($variable, $this->_globals))
{
return $this->_globals[$variable];
}
elseif(array_key_exists($variable, $this->_data))
{
return $this->_data[$variable];
}

return FALSE;
}
}
// End Class

0 comments on commit dd99efb

Please sign in to comment.