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
This commit is contained in:
nate 2006-08-22 07:32:59 +00:00
parent 4c45120b75
commit 8041562a76

View file

@ -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 * @deprecated
*/ */
function setLayout($layout) { function setLayout($layout) {
$this->layout = $layout; $this->layout = $layout;
} }
/** /**
* Allows a template or element to set a variable that will be available in * Allows a template or element to set a variable that will be available in
* a layout or other element. Analagous to Controller::set. * a layout or other element. Analagous to Controller::set.