Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make globals work if you access the the variables directly with
$v->foo instead of doing it in a rendered template.
  • Loading branch information
bharat committed Nov 26, 2009
1 parent 5f52101 commit ccb0ea3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions modules/gallery/libraries/MY_View.php
Expand Up @@ -27,6 +27,26 @@ public function set_global($key, $value) {
View::$global_data[$key] = $value;
}

public function is_set($key) {
return parent::is_set($key) ? true : array_key_exists($key, View::$global_data);
}

/**
* Completely replace View_Core::__get() so that local data trumps global data, trumps members.
* This simulates the Kohana 2.3 behavior.
*/
public function &__get($key) {
if (isset($this->kohana_local_data[$key])) {
return $this->kohana_local_data[$key];
} else if (isset(View::$global_data[$key])) {
return View::$global_data[$key];
} else if (isset($this->$key)) {
return $this->$key;
} else {
throw new Kohana_Exception('Undefined view variable: :var', array(':var' => $key));
}
}

/**
* Override View_Core::__construct so that we can set the csrf value into all views.
*
Expand Down

0 comments on commit ccb0ea3

Please sign in to comment.