diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-11-25 19:24:50 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-11-25 19:24:50 -0800 |
commit | ccb0ea3d30a114c069240453d7d85f18328db6e5 (patch) | |
tree | 12205d9c08ba13b685211b13eca8a97970848599 /modules | |
parent | 5f521014f68803bb0bbab5fe30e1e2c5f61d1b37 (diff) |
Make globals work if you access the the variables directly with
$v->foo instead of doing it in a rendered template.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gallery/libraries/MY_View.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/modules/gallery/libraries/MY_View.php b/modules/gallery/libraries/MY_View.php index 45aae188..cec59ec1 100644 --- a/modules/gallery/libraries/MY_View.php +++ b/modules/gallery/libraries/MY_View.php @@ -27,6 +27,26 @@ class View extends View_Core { 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. * |