ViewResponse类增加getVars方法

This commit is contained in:
thinkphp
2016-06-14 11:49:07 +08:00
parent 2e35cf1cb0
commit af648cfa8d

View File

@@ -38,7 +38,7 @@ class View extends Response
/** /**
* 视图变量赋值 * 视图变量赋值
* @access protected * @access public
* @param array $vars 模板变量 * @param array $vars 模板变量
* @return $this * @return $this
*/ */
@@ -48,6 +48,21 @@ class View extends Response
return $this; return $this;
} }
/**
* 获取视图变量
* @access public
* @param string $name 模板变量
* @return mixed
*/
public function getVars($name = null)
{
if(is_null($name)){
return $this->vars;
}else{
return isset($this->vars[$name]) ? $this->vars[$name] : null;
}
}
/** /**
* 模板变量赋值 * 模板变量赋值
* @access public * @access public