mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
[更新]ComposerUpdate
This commit is contained in:
parent
43e8ccbbe1
commit
d42b51015e
@ -415,26 +415,11 @@ class App extends Container
|
||||
// 监听app_dispatch
|
||||
$this->hook->listen('app_dispatch');
|
||||
|
||||
// 获取应用调度信息
|
||||
if (!$this->appDebug && $this->config->get('route_check_cache')) {
|
||||
$routeKey = $this->getRouteCacheKey();
|
||||
|
||||
if ($this->cache->has($routeKey)) {
|
||||
$this->dispatch = $this->cache->get($routeKey);
|
||||
}
|
||||
}
|
||||
|
||||
$dispatch = $this->dispatch;
|
||||
|
||||
if (empty($dispatch)) {
|
||||
// 路由检测
|
||||
$dispatch = $this->routeCheck();
|
||||
|
||||
try {
|
||||
if (isset($routeKey)) {
|
||||
$this->cache->tag('route_cache')->set($routeKey, $dispatch);
|
||||
}
|
||||
} catch (\Exception $e) {}
|
||||
}
|
||||
|
||||
// 记录当前调度信息
|
||||
@ -569,6 +554,15 @@ class App extends Container
|
||||
*/
|
||||
public function routeCheck()
|
||||
{
|
||||
// 获取应用调度信息
|
||||
if (!$this->appDebug && $this->config->get('route_check_cache')) {
|
||||
$routeKey = $this->getRouteCacheKey();
|
||||
|
||||
if ($this->cache->has($routeKey)) {
|
||||
return $this->cache->get($routeKey);
|
||||
}
|
||||
}
|
||||
|
||||
$path = $this->request->path();
|
||||
|
||||
// 路由检测
|
||||
@ -605,7 +599,19 @@ class App extends Container
|
||||
$must = !is_null($this->routeMust) ? $this->routeMust : $this->route->config('url_route_must');
|
||||
|
||||
// 路由检测 返回一个Dispatch对象
|
||||
return $this->route->check($path, $must);
|
||||
$dispatch = $this->route->check($path, $must);
|
||||
|
||||
if (!empty($routeKey)) {
|
||||
try {
|
||||
$this->cache
|
||||
->tag('route_cache')
|
||||
->set($routeKey, $dispatch);
|
||||
} catch (\Exception $e) {
|
||||
// 存在闭包的时候缓存无效
|
||||
}
|
||||
}
|
||||
|
||||
return $dispatch;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -237,7 +237,7 @@ class Debug
|
||||
$output = '<pre>' . $label . $output . '</pre>';
|
||||
}
|
||||
if ($echo) {
|
||||
echo ($output);
|
||||
echo($output);
|
||||
return;
|
||||
}
|
||||
return $output;
|
||||
|
@ -15,8 +15,6 @@ use think\Route;
|
||||
|
||||
class AliasRule extends Domain
|
||||
{
|
||||
protected $route;
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
* @access public
|
||||
@ -36,7 +34,7 @@ class AliasRule extends Domain
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测域名路由
|
||||
* 检测路由别名
|
||||
* @access public
|
||||
* @param Request $request 请求对象
|
||||
* @param string $url 访问地址
|
||||
@ -113,13 +111,4 @@ class AliasRule extends Domain
|
||||
return $this->option('except', $action);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前的路由
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getRoute()
|
||||
{
|
||||
return $this->route;
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ use think\Container;
|
||||
use think\exception\ValidateException;
|
||||
use think\Request;
|
||||
use think\Response;
|
||||
use think\route\dispatch\ResponseDispatch;
|
||||
|
||||
abstract class Dispatch
|
||||
{
|
||||
@ -33,9 +32,9 @@ abstract class Dispatch
|
||||
|
||||
/**
|
||||
* 路由规则
|
||||
* @var RuleItem
|
||||
* @var Rule
|
||||
*/
|
||||
protected $router;
|
||||
protected $rule;
|
||||
|
||||
/**
|
||||
* 调度信息
|
||||
@ -61,10 +60,10 @@ abstract class Dispatch
|
||||
*/
|
||||
protected $convert;
|
||||
|
||||
public function __construct(Request $request, RuleItem $router, $dispatch, $param = [], $code = null)
|
||||
public function __construct(Request $request, Rule $rule, $dispatch, $param = [], $code = null)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->router = $router;
|
||||
$this->rule = $rule;
|
||||
$this->app = Container::get('app');
|
||||
$this->dispatch = $dispatch;
|
||||
$this->param = $param;
|
||||
@ -74,16 +73,18 @@ abstract class Dispatch
|
||||
$this->convert = $param['convert'];
|
||||
}
|
||||
|
||||
// 设置请求的路由信息
|
||||
$this->request->routeInfo([
|
||||
'rule' => $this->router->getRule(),
|
||||
'route' => $this->router->getRoute(),
|
||||
'option' => $this->router->getOption(),
|
||||
'var' => $this->router->getVars(),
|
||||
]);
|
||||
|
||||
// 执行路由后置操作
|
||||
$this->routeAfter();
|
||||
if ($this->rule->doAfter()) {
|
||||
// 设置请求的路由信息
|
||||
$this->request->routeInfo([
|
||||
'rule' => $this->rule->getRule(),
|
||||
'route' => $this->rule->getRoute(),
|
||||
'option' => $this->rule->getOption(),
|
||||
'var' => $this->rule->getVars(),
|
||||
]);
|
||||
|
||||
$this->doRouteAfter();
|
||||
}
|
||||
|
||||
// 初始化
|
||||
$this->init();
|
||||
@ -97,11 +98,11 @@ abstract class Dispatch
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function routeAfter()
|
||||
protected function doRouteAfter()
|
||||
{
|
||||
// 记录匹配的路由信息
|
||||
$option = $this->router->getOption();
|
||||
$matches = $this->router->getVars();
|
||||
$option = $this->rule->getOption();
|
||||
$matches = $this->rule->getVars();
|
||||
|
||||
// 添加中间件
|
||||
if (!empty($option['middleware'])) {
|
||||
@ -143,7 +144,7 @@ abstract class Dispatch
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$option = $this->router->getOption();
|
||||
$option = $this->rule->getOption();
|
||||
|
||||
// 检测路由after行为
|
||||
if (!empty($option['after'])) {
|
||||
@ -156,7 +157,7 @@ abstract class Dispatch
|
||||
|
||||
// 数据自动验证
|
||||
if (isset($option['validate'])) {
|
||||
$this->autoValidate($option['validate'], $request);
|
||||
$this->autoValidate($option['validate']);
|
||||
}
|
||||
|
||||
return $this->exec();
|
||||
@ -186,7 +187,7 @@ abstract class Dispatch
|
||||
|
||||
// 路由规则重定向
|
||||
if ($result instanceof Response) {
|
||||
return new ResponseDispatch($result, $this->router);
|
||||
return $result;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -196,11 +197,10 @@ abstract class Dispatch
|
||||
* 验证数据
|
||||
* @access protected
|
||||
* @param array $option
|
||||
* @param \think\Request $request
|
||||
* @return void
|
||||
* @throws ValidateException
|
||||
*/
|
||||
protected function autoValidate($option, $request)
|
||||
protected function autoValidate($option)
|
||||
{
|
||||
list($validate, $scene, $message, $batch) = $option;
|
||||
|
||||
@ -225,7 +225,7 @@ abstract class Dispatch
|
||||
$v->batch(true);
|
||||
}
|
||||
|
||||
if (!$v->check($request->param())) {
|
||||
if (!$v->check($this->request->param())) {
|
||||
throw new ValidateException($v->getError());
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ class Domain extends RuleGroup
|
||||
$this->parseUrlParams($request, $array[1]);
|
||||
}
|
||||
|
||||
return new CallbackDispatch($request, $this->router, [$class, $action]);
|
||||
return new CallbackDispatch($request, $this, [$class, $action]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -189,7 +189,7 @@ class Domain extends RuleGroup
|
||||
$this->parseUrlParams($request, $array[2]);
|
||||
}
|
||||
|
||||
return new CallbackDispatch($request, $this->router, [$namespace . '\\' . Loader::parseName($class, 1), $method]);
|
||||
return new CallbackDispatch($request, $this, [$namespace . '\\' . Loader::parseName($class, 1), $method]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -209,7 +209,7 @@ class Domain extends RuleGroup
|
||||
$this->parseUrlParams($request, $array[1]);
|
||||
}
|
||||
|
||||
return new ControllerDispatch($request, $this->router, $controller . '/' . $action);
|
||||
return new ControllerDispatch($request, $this, $controller . '/' . $action);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -229,7 +229,7 @@ class Domain extends RuleGroup
|
||||
$this->parseUrlParams($request, $array[1]);
|
||||
}
|
||||
|
||||
return new ModuleDispatch($request, $this->router, $controller . '/' . $action);
|
||||
return new ModuleDispatch($request, $this, $controller . '/' . $action);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,8 +17,7 @@ class Resource extends RuleGroup
|
||||
{
|
||||
// 资源路由名称
|
||||
protected $resource;
|
||||
// 资源路由地址
|
||||
protected $route;
|
||||
|
||||
// REST路由方法定义
|
||||
protected $rest = [];
|
||||
|
||||
|
@ -23,20 +23,195 @@ use think\route\dispatch\View as ViewDispatch;
|
||||
|
||||
abstract class Rule
|
||||
{
|
||||
/**
|
||||
* 路由标识
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
// 路由对象实例
|
||||
|
||||
/**
|
||||
* 路由对象
|
||||
* @var Route
|
||||
*/
|
||||
protected $router;
|
||||
// 路由父对象
|
||||
|
||||
/**
|
||||
* 路由所属分组
|
||||
* @var RuleGroup
|
||||
*/
|
||||
protected $parent;
|
||||
// 路由参数
|
||||
|
||||
/**
|
||||
* 路由规则
|
||||
* @var mixed
|
||||
*/
|
||||
protected $rule;
|
||||
|
||||
/**
|
||||
* 路由地址
|
||||
* @var string|\Closure
|
||||
*/
|
||||
protected $route;
|
||||
|
||||
/**
|
||||
* 请求类型
|
||||
* @var string
|
||||
*/
|
||||
protected $method;
|
||||
|
||||
/**
|
||||
* 路由变量
|
||||
* @var array
|
||||
*/
|
||||
protected $vars = [];
|
||||
|
||||
/**
|
||||
* 路由参数
|
||||
* @var array
|
||||
*/
|
||||
protected $option = [];
|
||||
// 路由变量规则
|
||||
|
||||
/**
|
||||
* 路由变量规则
|
||||
* @var array
|
||||
*/
|
||||
protected $pattern = [];
|
||||
// 需要合并的路由参数
|
||||
|
||||
/**
|
||||
* 需要和分组合并的路由参数
|
||||
* @var array
|
||||
*/
|
||||
protected $mergeOptions = ['after', 'before', 'model', 'header', 'response', 'append', 'middleware'];
|
||||
|
||||
/**
|
||||
* 是否需要后置操作
|
||||
* @var bool
|
||||
*/
|
||||
protected $doAfter;
|
||||
|
||||
abstract public function check($request, $url, $depr = '/');
|
||||
|
||||
/**
|
||||
* 获取Name
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前路由规则
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getRule()
|
||||
{
|
||||
return $this->rule;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前路由地址
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function getRoute()
|
||||
{
|
||||
return $this->route;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前路由的请求类型
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return strtolower($this->method);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前路由的变量
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getVars()
|
||||
{
|
||||
return $this->vars;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路由对象
|
||||
* @access public
|
||||
* @return Route
|
||||
*/
|
||||
public function getRouter()
|
||||
{
|
||||
return $this->router;
|
||||
}
|
||||
|
||||
/**
|
||||
* 路由是否有后置操作
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function doAfter()
|
||||
{
|
||||
return $this->doAfter;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路由分组
|
||||
* @access public
|
||||
* @return RuleGroup|null
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取变量规则定义
|
||||
* @access public
|
||||
* @param string $name 变量名
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPattern($name = '')
|
||||
{
|
||||
if ('' === $name) {
|
||||
return $this->pattern;
|
||||
}
|
||||
|
||||
return isset($this->pattern[$name]) ? $this->pattern[$name] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路由参数
|
||||
* @access public
|
||||
* @param string $name 变量名
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConfig($name = '')
|
||||
{
|
||||
return $this->router->config($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路由参数定义
|
||||
* @access public
|
||||
* @param string $name 参数名
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOption($name = '')
|
||||
{
|
||||
if ('' === $name) {
|
||||
return $this->option;
|
||||
}
|
||||
|
||||
return isset($this->option[$name]) ? $this->option[$name] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册路由参数
|
||||
* @access public
|
||||
@ -86,77 +261,6 @@ abstract class Rule
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Name
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Parent对象
|
||||
* @access public
|
||||
* @return $this|null
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取变量规则定义
|
||||
* @access public
|
||||
* @param string $name 变量名
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPattern($name = '')
|
||||
{
|
||||
if ('' === $name) {
|
||||
return $this->pattern;
|
||||
}
|
||||
|
||||
return isset($this->pattern[$name]) ? $this->pattern[$name] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路由参数
|
||||
* @access public
|
||||
* @param string $name 变量名
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConfig($name = '')
|
||||
{
|
||||
return $this->router->config($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路由对象
|
||||
* @access public
|
||||
* @return Route
|
||||
*/
|
||||
public function getRouter()
|
||||
{
|
||||
return $this->router;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路由参数定义
|
||||
* @access public
|
||||
* @param string $name 参数名
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOption($name = '')
|
||||
{
|
||||
if ('' === $name) {
|
||||
return $this->option;
|
||||
}
|
||||
|
||||
return isset($this->option[$name]) ? $this->option[$name] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置路由请求类型
|
||||
* @access public
|
||||
@ -582,9 +686,10 @@ abstract class Rule
|
||||
$url = array_slice(explode('|', $url), $count + 1);
|
||||
$this->parseUrlParams($request, implode('|', $url), $matches);
|
||||
|
||||
$this->route = $route;
|
||||
$this->vars = $matches;
|
||||
$this->option = $option;
|
||||
$this->route = $route;
|
||||
$this->vars = $matches;
|
||||
$this->option = $option;
|
||||
$this->doAfter = true;
|
||||
|
||||
// 发起路由调度
|
||||
return $this->dispatch($request, $route, $option);
|
||||
|
@ -33,8 +33,6 @@ class RuleGroup extends Rule
|
||||
'options' => [],
|
||||
];
|
||||
|
||||
protected $rule;
|
||||
|
||||
// MISS路由
|
||||
protected $miss;
|
||||
|
||||
@ -131,7 +129,7 @@ class RuleGroup extends Rule
|
||||
$this->buildResourceRule($this->resource, $this->option);
|
||||
} elseif ($this->rule) {
|
||||
if ($this->rule instanceof Response) {
|
||||
return new ResponseDispatch($request, $this->router, $this->rule);
|
||||
return new ResponseDispatch($request, $this, $this->rule);
|
||||
}
|
||||
|
||||
$this->parseGroupRule($this->rule);
|
||||
@ -176,12 +174,10 @@ class RuleGroup extends Rule
|
||||
|
||||
if ($this->auto) {
|
||||
// 自动解析URL地址
|
||||
$ruleItem = new RuleItem($this->router, $this, '', '', $this->auto . '/' . $url);
|
||||
$result = new UrlDispatch($request, $ruleItem, $this->auto . '/' . $url, ['auto_search' => false]);
|
||||
$result = new UrlDispatch($request, $this, $this->auto . '/' . $url, ['auto_search' => false]);
|
||||
} elseif ($this->miss && in_array($this->miss->getMethod(), ['*', $method])) {
|
||||
// 未匹配所有路由的路由规则处理
|
||||
$ruleItem = new RuleItem($this->router, $this, '', '', $this->miss->getRoute());
|
||||
$result = $ruleItem->parseRule($request, '', $this->miss->getRoute(), $url, $this->miss->getOption());
|
||||
$result = $this->miss->parseRule($request, '', $this->miss->getRoute(), $url, $this->miss->getOption());
|
||||
} else {
|
||||
$result = false;
|
||||
}
|
||||
|
@ -17,30 +17,6 @@ use think\Route;
|
||||
|
||||
class RuleItem extends Rule
|
||||
{
|
||||
/**
|
||||
* 路由规则
|
||||
* @var string
|
||||
*/
|
||||
protected $rule;
|
||||
|
||||
/**
|
||||
* 路由地址
|
||||
* @var string|\Closure
|
||||
*/
|
||||
protected $route;
|
||||
|
||||
/**
|
||||
* 请求类型
|
||||
* @var string
|
||||
*/
|
||||
protected $method;
|
||||
|
||||
/**
|
||||
* 路由变量
|
||||
* @var array
|
||||
*/
|
||||
protected $vars = [];
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
* @access public
|
||||
@ -48,8 +24,8 @@ class RuleItem extends Rule
|
||||
* @param RuleGroup $parent 上级对象
|
||||
* @param string $name 路由标识
|
||||
* @param string|array $rule 路由规则
|
||||
* @param string $method 请求类型
|
||||
* @param string|\Closure $route 路由地址
|
||||
* @param string $method 请求类型
|
||||
* @param array $option 路由参数
|
||||
* @param array $pattern 变量规则
|
||||
*/
|
||||
@ -101,46 +77,6 @@ class RuleItem extends Rule
|
||||
$this->setRuleName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前路由规则
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getRule()
|
||||
{
|
||||
return $this->rule;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前路由地址
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function getRoute()
|
||||
{
|
||||
return $this->route;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前路由的请求类型
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return strtolower($this->method);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前路由的变量
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getVars()
|
||||
{
|
||||
return $this->vars;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查后缀
|
||||
* @access public
|
||||
|
@ -22,8 +22,8 @@ class Controller extends Dispatch
|
||||
|
||||
return $this->app->action(
|
||||
$this->dispatch, $vars,
|
||||
$this->router->getConfig('url_controller_layer'),
|
||||
$this->router->getConfig('controller_suffix')
|
||||
$this->rule->getConfig('url_controller_layer'),
|
||||
$this->rule->getConfig('controller_suffix')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -30,10 +30,10 @@ class Module extends Dispatch
|
||||
$result = explode('/', $result);
|
||||
}
|
||||
|
||||
if ($this->router->getConfig('app_multi_module')) {
|
||||
if ($this->rule->getConfig('app_multi_module')) {
|
||||
// 多模块部署
|
||||
$module = strip_tags(strtolower($result[0] ?: $this->router->getConfig('default_module')));
|
||||
$bind = $this->router->getRouter()->getBind();
|
||||
$module = strip_tags(strtolower($result[0] ?: $this->rule->getConfig('default_module')));
|
||||
$bind = $this->rule->getRouter()->getBind();
|
||||
$available = false;
|
||||
|
||||
if ($bind && preg_match('/^[a-z]/is', $bind)) {
|
||||
@ -43,10 +43,10 @@ class Module extends Dispatch
|
||||
$module = $bindModule;
|
||||
}
|
||||
$available = true;
|
||||
} elseif (!in_array($module, $this->router->getConfig('deny_module_list')) && is_dir($this->app->getAppPath() . $module)) {
|
||||
} elseif (!in_array($module, $this->rule->getConfig('deny_module_list')) && is_dir($this->app->getAppPath() . $module)) {
|
||||
$available = true;
|
||||
} elseif ($this->router->getConfig('empty_module')) {
|
||||
$module = $this->router->getConfig('empty_module');
|
||||
} elseif ($this->rule->getConfig('empty_module')) {
|
||||
$module = $this->rule->getConfig('empty_module');
|
||||
$available = true;
|
||||
}
|
||||
|
||||
@ -61,13 +61,13 @@ class Module extends Dispatch
|
||||
}
|
||||
|
||||
// 是否自动转换控制器和操作名
|
||||
$convert = is_bool($this->convert) ? $this->convert : $this->router->getConfig('url_convert');
|
||||
$convert = is_bool($this->convert) ? $this->convert : $this->rule->getConfig('url_convert');
|
||||
// 获取控制器名
|
||||
$controller = strip_tags($result[1] ?: $this->router->getConfig('default_controller'));
|
||||
$controller = strip_tags($result[1] ?: $this->rule->getConfig('default_controller'));
|
||||
$this->controller = $convert ? strtolower($controller) : $controller;
|
||||
|
||||
// 获取操作名
|
||||
$this->actionName = strip_tags($result[2] ?: $this->router->getConfig('default_action'));
|
||||
$this->actionName = strip_tags($result[2] ?: $this->rule->getConfig('default_action'));
|
||||
|
||||
// 设置当前请求的控制器、操作
|
||||
$this->request->controller(Loader::parseName($this->controller, 1))->action($this->actionName);
|
||||
@ -82,15 +82,15 @@ class Module extends Dispatch
|
||||
// 实例化控制器
|
||||
try {
|
||||
$instance = $this->app->controller($this->controller,
|
||||
$this->router->getConfig('url_controller_layer'),
|
||||
$this->router->getConfig('controller_suffix'),
|
||||
$this->router->getConfig('empty_controller'));
|
||||
$this->rule->getConfig('url_controller_layer'),
|
||||
$this->rule->getConfig('controller_suffix'),
|
||||
$this->rule->getConfig('empty_controller'));
|
||||
} catch (ClassNotFoundException $e) {
|
||||
throw new HttpException(404, 'controller not exists:' . $e->getClass());
|
||||
}
|
||||
|
||||
// 获取当前操作名
|
||||
$action = $this->actionName . $this->router->getConfig('action_suffix');
|
||||
$action = $this->actionName . $this->rule->getConfig('action_suffix');
|
||||
|
||||
if (is_callable([$instance, $action])) {
|
||||
// 执行操作方法
|
||||
@ -99,12 +99,12 @@ class Module extends Dispatch
|
||||
// 严格获取当前操作方法名
|
||||
$reflect = new ReflectionMethod($instance, $action);
|
||||
$methodName = $reflect->getName();
|
||||
$suffix = $this->router->getConfig('action_suffix');
|
||||
$suffix = $this->rule->getConfig('action_suffix');
|
||||
$actionName = $suffix ? substr($methodName, 0, -strlen($suffix)) : $methodName;
|
||||
$this->request->action($actionName);
|
||||
|
||||
// 自动获取请求变量
|
||||
$vars = $this->router->getConfig('url_param_type')
|
||||
$vars = $this->rule->getConfig('url_param_type')
|
||||
? $this->request->route()
|
||||
: $this->request->param();
|
||||
} elseif (is_callable([$instance, '_empty'])) {
|
||||
|
@ -20,10 +20,10 @@ class Url extends Dispatch
|
||||
protected function init()
|
||||
{
|
||||
// 解析默认的URL规则
|
||||
$depr = $this->router->getConfig('pathinfo_depr');
|
||||
$depr = $this->rule->getConfig('pathinfo_depr');
|
||||
$result = $this->parseUrl($this->dispatch, $depr);
|
||||
|
||||
$this->dispatch = new Module($this->request, $this->router, $result);
|
||||
$this->dispatch = new Module($this->request, $this->rule, $result);
|
||||
}
|
||||
|
||||
public function exec()
|
||||
@ -40,7 +40,7 @@ class Url extends Dispatch
|
||||
*/
|
||||
protected function parseUrl($url, $depr)
|
||||
{
|
||||
$bind = $this->router->getRouter()->getBind();
|
||||
$bind = $this->rule->getRouter()->getBind();
|
||||
|
||||
if (!empty($bind) && preg_match('/^[a-z]/is', $bind)) {
|
||||
$bind = str_replace('/', $depr, $bind);
|
||||
@ -54,7 +54,7 @@ class Url extends Dispatch
|
||||
}
|
||||
|
||||
// 解析模块
|
||||
$module = $this->router->getConfig('app_multi_module') ? array_shift($path) : null;
|
||||
$module = $this->rule->getConfig('app_multi_module') ? array_shift($path) : null;
|
||||
if ($this->param['auto_search']) {
|
||||
$controller = $this->autoFindController($module, $path);
|
||||
} else {
|
||||
@ -67,7 +67,7 @@ class Url extends Dispatch
|
||||
|
||||
// 解析额外参数
|
||||
if ($path) {
|
||||
if ($this->router->getConfig('url_param_type')) {
|
||||
if ($this->rule->getConfig('url_param_type')) {
|
||||
$var += $path;
|
||||
} else {
|
||||
preg_replace_callback('/(\w+)\|([^\|]+)/', function ($match) use (&$var) {
|
||||
@ -115,7 +115,7 @@ class Url extends Dispatch
|
||||
$name2 = strtolower(Loader::parseName($controller, 1) . '/' . $action);
|
||||
}
|
||||
|
||||
if ($this->router->getRouter()->getName($name) || $this->router->getRouter()->getName($name2)) {
|
||||
if ($this->rule->getRouter()->getName($name) || $this->rule->getRouter()->getName($name2)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -131,8 +131,8 @@ class Url extends Dispatch
|
||||
*/
|
||||
protected function autoFindController($module, &$path)
|
||||
{
|
||||
$dir = $this->app->getAppPath() . ($module ? $module . '/' : '') . $this->router->getConfig('url_controller_layer');
|
||||
$suffix = $this->app->getSuffix() || $this->router->getConfig('controller_suffix') ? ucfirst($this->router->getConfig('url_controller_layer')) : '';
|
||||
$dir = $this->app->getAppPath() . ($module ? $module . '/' : '') . $this->rule->getConfig('url_controller_layer');
|
||||
$suffix = $this->app->getSuffix() || $this->rule->getConfig('controller_suffix') ? ucfirst($this->rule->getConfig('url_controller_layer')) : '';
|
||||
|
||||
$item = [];
|
||||
$find = false;
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -4,4 +4,4 @@
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit513ee155225f84554dcc21f55f596f8f::getLoader();
|
||||
return ComposerAutoloaderInitf87766a7411e551cf24d607cb3736291::getLoader();
|
||||
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit513ee155225f84554dcc21f55f596f8f
|
||||
class ComposerAutoloaderInitf87766a7411e551cf24d607cb3736291
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -19,15 +19,15 @@ class ComposerAutoloaderInit513ee155225f84554dcc21f55f596f8f
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit513ee155225f84554dcc21f55f596f8f', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitf87766a7411e551cf24d607cb3736291', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit513ee155225f84554dcc21f55f596f8f', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitf87766a7411e551cf24d607cb3736291', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require_once __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit513ee155225f84554dcc21f55f596f8f::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitf87766a7411e551cf24d607cb3736291::getInitializer($loader));
|
||||
} else {
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
@ -48,19 +48,19 @@ class ComposerAutoloaderInit513ee155225f84554dcc21f55f596f8f
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit513ee155225f84554dcc21f55f596f8f::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInitf87766a7411e551cf24d607cb3736291::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire513ee155225f84554dcc21f55f596f8f($fileIdentifier, $file);
|
||||
composerRequiref87766a7411e551cf24d607cb3736291($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire513ee155225f84554dcc21f55f596f8f($fileIdentifier, $file)
|
||||
function composerRequiref87766a7411e551cf24d607cb3736291($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit513ee155225f84554dcc21f55f596f8f
|
||||
class ComposerStaticInitf87766a7411e551cf24d607cb3736291
|
||||
{
|
||||
public static $files = array (
|
||||
'1cfd2761b63b0a29ed23657ea394cb2d' => __DIR__ . '/..' . '/topthink/think-captcha/src/helper.php',
|
||||
@ -287,9 +287,9 @@ class ComposerStaticInit513ee155225f84554dcc21f55f596f8f
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit513ee155225f84554dcc21f55f596f8f::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit513ee155225f84554dcc21f55f596f8f::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit513ee155225f84554dcc21f55f596f8f::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitf87766a7411e551cf24d607cb3736291::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitf87766a7411e551cf24d607cb3736291::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitf87766a7411e551cf24d607cb3736291::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
20
vendor/composer/installed.json
vendored
20
vendor/composer/installed.json
vendored
@ -80,17 +80,17 @@
|
||||
},
|
||||
{
|
||||
"name": "zoujingli/wechat-developer",
|
||||
"version": "v1.1.6",
|
||||
"version_normalized": "1.1.6.0",
|
||||
"version": "v1.1.7",
|
||||
"version_normalized": "1.1.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/zoujingli/WeChatDeveloper.git",
|
||||
"reference": "095471bdc61e3389135f69b1849069c19d439f22"
|
||||
"reference": "f01ac5dafc85cb408fd3e0bafc462437785ae178"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://files.phpcomposer.com/files/zoujingli/WeChatDeveloper/095471bdc61e3389135f69b1849069c19d439f22.zip",
|
||||
"reference": "095471bdc61e3389135f69b1849069c19d439f22",
|
||||
"url": "https://files.phpcomposer.com/files/zoujingli/WeChatDeveloper/f01ac5dafc85cb408fd3e0bafc462437785ae178.zip",
|
||||
"reference": "f01ac5dafc85cb408fd3e0bafc462437785ae178",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -98,7 +98,7 @@
|
||||
"ext-openssl": "*",
|
||||
"php": ">=5.4"
|
||||
},
|
||||
"time": "2018-05-11T09:54:48+00:00",
|
||||
"time": "2018-05-16T05:48:16+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
@ -183,12 +183,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/top-think/framework.git",
|
||||
"reference": "1adc81f2d59cd99e69d38c058527cd759531e8a8"
|
||||
"reference": "6448c4b42599d58125ba1307aa6d3defa044aeb9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://files.phpcomposer.com/files/top-think/framework/1adc81f2d59cd99e69d38c058527cd759531e8a8.zip",
|
||||
"reference": "1adc81f2d59cd99e69d38c058527cd759531e8a8",
|
||||
"url": "https://files.phpcomposer.com/files/top-think/framework/6448c4b42599d58125ba1307aa6d3defa044aeb9.zip",
|
||||
"reference": "6448c4b42599d58125ba1307aa6d3defa044aeb9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -204,7 +204,7 @@
|
||||
"sebastian/phpcpd": "2.*",
|
||||
"squizlabs/php_codesniffer": "2.*"
|
||||
},
|
||||
"time": "2018-05-19T04:16:33+00:00",
|
||||
"time": "2018-05-19T13:37:11+00:00",
|
||||
"type": "think-framework",
|
||||
"installation-source": "dist",
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
|
@ -35,6 +35,8 @@ try {
|
||||
$result = $wechat->createTransfers($options);
|
||||
echo '<pre>';
|
||||
var_export($result);
|
||||
$result = $wechat->queryTransfers($options['partner_trade_no']);
|
||||
var_export($result);
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
|
@ -155,7 +155,7 @@ class Tools
|
||||
{
|
||||
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', function ($matches) {
|
||||
return mb_convert_encoding(pack("H*", $matches[1]), "UTF-8", "UCS-2BE");
|
||||
}, json_encode($data));
|
||||
}, ($jsonData = json_encode($data)) == '[]' ? '{}' : $jsonData);
|
||||
}
|
||||
|
||||
/**
|
||||
|
24
vendor/zoujingli/wechat-developer/WeChat/Pay.php
vendored
24
vendor/zoujingli/wechat-developer/WeChat/Pay.php
vendored
@ -202,14 +202,23 @@ class Pay
|
||||
|
||||
/**
|
||||
* 下载对账单
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @param array $options 静音参数
|
||||
* @param null|string $outType 输出类型
|
||||
* @return bool|string
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function billDownload(array $options)
|
||||
public function billDownload(array $options, $outType = null)
|
||||
{
|
||||
$url = 'https://api.mch.weixin.qq.com/pay/downloadbill';
|
||||
return $this->callPostApi($url, $options);
|
||||
$this->params->set('sign_type', 'MD5');
|
||||
$params = $this->params->merge($options);
|
||||
$params['sign'] = $this->getPaySign($params, 'MD5');
|
||||
$result = Tools::post('https://api.mch.weixin.qq.com/pay/downloadbill', Tools::arr2xml($params));
|
||||
if (($jsonData = Tools::xml2arr($result))) {
|
||||
if ($jsonData['return_code'] !== 'SUCCESS') {
|
||||
throw new InvalidResponseException($jsonData['return_msg'], '0');
|
||||
}
|
||||
}
|
||||
return is_null($outType) ? $result : $outType($result);
|
||||
}
|
||||
|
||||
|
||||
@ -250,6 +259,10 @@ class Pay
|
||||
public function queryTransfers($partner_trade_no)
|
||||
{
|
||||
$url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/gettransferinfo';
|
||||
$this->params->set('appid', $this->config->get('appid'));
|
||||
$this->params->set('mch_id', $this->config->get('mch_id'));
|
||||
$this->params->offsetUnset('mchid');
|
||||
$this->params->offsetUnset('mch_appid');
|
||||
return $this->callPostApi($url, ['partner_trade_no' => $partner_trade_no], true, 'MD5', false);
|
||||
}
|
||||
|
||||
@ -297,6 +310,7 @@ class Pay
|
||||
*/
|
||||
public function queryTransFresBank($partner_trade_no)
|
||||
{
|
||||
$this->params->offsetUnset('appid');
|
||||
$url = 'https://api.mch.weixin.qq.com/mmpaysptrans/query_bank';
|
||||
return $this->callPostApi($url, ['partner_trade_no' => $partner_trade_no], true, 'MD5', false);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user