mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +08:00
Request类增加bind方法用于动态绑定属性 Route类的模型绑定直接绑定到Request实例对象的属性 便于获取
This commit is contained in:
@@ -115,6 +115,8 @@ class Request
|
|||||||
protected $filter;
|
protected $filter;
|
||||||
// Hook扩展方法
|
// Hook扩展方法
|
||||||
protected static $hook = [];
|
protected static $hook = [];
|
||||||
|
// 绑定的属性
|
||||||
|
protected $bind = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 架构函数
|
* 架构函数
|
||||||
@@ -1436,4 +1438,30 @@ class Request
|
|||||||
Session::set($name, $token);
|
Session::set($name, $token);
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置当前请求绑定的对象实例
|
||||||
|
* @access public
|
||||||
|
* @param string $name 绑定的对象标识
|
||||||
|
* @param mixed $obj 绑定的对象实例
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function bind($name, $obj = null)
|
||||||
|
{
|
||||||
|
if (is_array($name)) {
|
||||||
|
$this->bind = array_merge($this->bind, $name);
|
||||||
|
} else {
|
||||||
|
$this->bind[$name] = $obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __set($name, $value)
|
||||||
|
{
|
||||||
|
$this->bind[$name] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __get($name)
|
||||||
|
{
|
||||||
|
return isset($this->bind[$name]) ? $this->bind[$name] : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1367,7 +1367,7 @@ class Route
|
|||||||
$bind[$key] = $result;
|
$bind[$key] = $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$matches = array_merge($matches, $bind);
|
Request::instance()->bind($bind);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解析额外参数
|
// 解析额外参数
|
||||||
|
|||||||
Reference in New Issue
Block a user