mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 23:52:49 +08:00
修正Controller类
This commit is contained in:
@@ -94,61 +94,61 @@ class Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载模板输出
|
* 加载模板输出
|
||||||
* @access public
|
* @access protected
|
||||||
* @param string $template 模板文件名
|
* @param string $template 模板文件名
|
||||||
* @param array $vars 模板输出变量
|
* @param array $vars 模板输出变量
|
||||||
* @param array $replace 模板替换
|
* @param array $replace 模板替换
|
||||||
* @param array $config 模板参数
|
* @param array $config 模板参数
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function fetch($template = '', $vars = [], $replace = [], $config = [])
|
protected function fetch($template = '', $vars = [], $replace = [], $config = [])
|
||||||
{
|
{
|
||||||
return $this->view->fetch($template, $vars, $replace, $config);
|
return $this->view->fetch($template, $vars, $replace, $config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 渲染内容输出
|
* 渲染内容输出
|
||||||
* @access public
|
* @access protected
|
||||||
* @param string $content 模板内容
|
* @param string $content 模板内容
|
||||||
* @param array $vars 模板输出变量
|
* @param array $vars 模板输出变量
|
||||||
* @param array $config 模板参数
|
* @param array $config 模板参数
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function display($content = '', $vars = [], $config = [])
|
protected function display($content = '', $vars = [], $config = [])
|
||||||
{
|
{
|
||||||
return $this->view->display($content, $vars, $config);
|
return $this->view->display($content, $vars, $config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模板变量赋值
|
* 模板变量赋值
|
||||||
* @access public
|
* @access protected
|
||||||
* @param mixed $name 要显示的模板变量
|
* @param mixed $name 要显示的模板变量
|
||||||
* @param mixed $value 变量的值
|
* @param mixed $value 变量的值
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function assign($name, $value = '')
|
protected function assign($name, $value = '')
|
||||||
{
|
{
|
||||||
$this->view->assign($name, $value);
|
$this->view->assign($name, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化模板引擎
|
* 初始化模板引擎
|
||||||
* @access public
|
* @access protected
|
||||||
* @param array|string $engine 引擎参数
|
* @param array|string $engine 引擎参数
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function engine($engine)
|
protected function engine($engine)
|
||||||
{
|
{
|
||||||
$this->view->engine($engine);
|
$this->view->engine($engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置验证失败后是否抛出异常
|
* 设置验证失败后是否抛出异常
|
||||||
* @access public
|
* @access protected
|
||||||
* @param bool $fail 是否抛出异常
|
* @param bool $fail 是否抛出异常
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function failException($fail = true)
|
protected function failException($fail = true)
|
||||||
{
|
{
|
||||||
$this->failException = $fail;
|
$this->failException = $fail;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -156,14 +156,14 @@ class Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证数据
|
* 验证数据
|
||||||
* @access public
|
* @access protected
|
||||||
* @param array $data 数据
|
* @param array $data 数据
|
||||||
* @param string|array $validate 验证器名或者验证规则数组
|
* @param string|array $validate 验证器名或者验证规则数组
|
||||||
* @param array $message 提示信息
|
* @param array $message 提示信息
|
||||||
* @param mixed $callback 回调方法(闭包)
|
* @param mixed $callback 回调方法(闭包)
|
||||||
* @return true|string|array
|
* @return true|string|array
|
||||||
*/
|
*/
|
||||||
public function validate($data, $validate, $message = [], $callback = null)
|
protected function validate($data, $validate, $message = [], $callback = null)
|
||||||
{
|
{
|
||||||
if (is_array($validate)) {
|
if (is_array($validate)) {
|
||||||
$v = Loader::validate();
|
$v = Loader::validate();
|
||||||
|
|||||||
@@ -25,14 +25,14 @@ trait Jump
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 操作成功跳转的快捷方法
|
* 操作成功跳转的快捷方法
|
||||||
* @access public
|
* @access protected
|
||||||
* @param mixed $msg 提示信息
|
* @param mixed $msg 提示信息
|
||||||
* @param string $url 跳转的URL地址
|
* @param string $url 跳转的URL地址
|
||||||
* @param mixed $data 返回的数据
|
* @param mixed $data 返回的数据
|
||||||
* @param integer $wait 跳转等待时间
|
* @param integer $wait 跳转等待时间
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function success($msg = '', $url = null, $data = '', $wait = 3)
|
protected function success($msg = '', $url = null, $data = '', $wait = 3)
|
||||||
{
|
{
|
||||||
$code = 1;
|
$code = 1;
|
||||||
if (is_numeric($msg)) {
|
if (is_numeric($msg)) {
|
||||||
@@ -57,14 +57,14 @@ trait Jump
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作错误跳转的快捷方法
|
* 操作错误跳转的快捷方法
|
||||||
* @access public
|
* @access protected
|
||||||
* @param mixed $msg 提示信息
|
* @param mixed $msg 提示信息
|
||||||
* @param string $url 跳转的URL地址
|
* @param string $url 跳转的URL地址
|
||||||
* @param mixed $data 返回的数据
|
* @param mixed $data 返回的数据
|
||||||
* @param integer $wait 跳转等待时间
|
* @param integer $wait 跳转等待时间
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function error($msg = '', $url = null, $data = '', $wait = 3)
|
protected function error($msg = '', $url = null, $data = '', $wait = 3)
|
||||||
{
|
{
|
||||||
$code = 0;
|
$code = 0;
|
||||||
if (is_numeric($msg)) {
|
if (is_numeric($msg)) {
|
||||||
@@ -90,14 +90,14 @@ trait Jump
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回封装后的API数据到客户端
|
* 返回封装后的API数据到客户端
|
||||||
* @access public
|
* @access protected
|
||||||
* @param mixed $data 要返回的数据
|
* @param mixed $data 要返回的数据
|
||||||
* @param integer $code 返回的code
|
* @param integer $code 返回的code
|
||||||
* @param mixed $msg 提示信息
|
* @param mixed $msg 提示信息
|
||||||
* @param string $type 返回数据格式
|
* @param string $type 返回数据格式
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function result($data, $code = 0, $msg = '', $type = '')
|
protected function result($data, $code = 0, $msg = '', $type = '')
|
||||||
{
|
{
|
||||||
return Response::create([], $type)->result($data, $code, $msg);
|
return Response::create([], $type)->result($data, $code, $msg);
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ trait Jump
|
|||||||
* @param integer $code http code
|
* @param integer $code http code
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function redirect($url, $params = [], $code = 302)
|
protected function redirect($url, $params = [], $code = 302)
|
||||||
{
|
{
|
||||||
$response = new Redirect($url);
|
$response = new Redirect($url);
|
||||||
if (is_integer($params)) {
|
if (is_integer($params)) {
|
||||||
@@ -123,10 +123,10 @@ trait Jump
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前的response 输出类型
|
* 获取当前的response 输出类型
|
||||||
* @access public
|
* @access protected
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getResponseType()
|
protected function getResponseType()
|
||||||
{
|
{
|
||||||
$isAjax = Request::instance()->isAjax();
|
$isAjax = Request::instance()->isAjax();
|
||||||
return $isAjax ? Config::get('default_ajax_return') : Config::get('default_return_type');
|
return $isAjax ? Config::get('default_ajax_return') : Config::get('default_return_type');
|
||||||
|
|||||||
Reference in New Issue
Block a user