From 8041562a761b34d3b5296c0be6d89f75c9fa0653 Mon Sep 17 00:00:00 2001 From: nate Date: Tue, 22 Aug 2006 07:32:59 +0000 Subject: [PATCH] Adding variable access convenience methods to View git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3423 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/view/view.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index 5a1e0d927..17e7b752d 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -453,14 +453,34 @@ class View extends Object{ )); } } - +/** + * Returns a list of variables available in the current View context + * + * @return array + * @access public + */ + function getVars() { + return array_keys($this->_viewVars); + } +/** + * Returns the contents of the given View variable(s) + * + * @return array + * @access public + */ + function getVar($var) { + if (!isset($this->_viewVars[$var])) { + return null; + } else { + return $this->_viewVars[$var]; + } + } /** * @deprecated */ function setLayout($layout) { $this->layout = $layout; } - /** * Allows a template or element to set a variable that will be available in * a layout or other element. Analagous to Controller::set.