Skip to content

Commit

Permalink
请求controller方法获取调整
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Oct 25, 2024
1 parent d99d243 commit 5fa4125
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/think/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ public function param($name = '', $default = null, string | array | null $filter
};

// 当前请求参数和URL地址中的参数合并
$this->param = array_merge($this->param, $this->get(false), $vars, $this->route(false));
$this->param = array_merge($this->param, $this->route(false), $this->get(false), $vars);

$this->mergeParam = true;
}
Expand Down
14 changes: 11 additions & 3 deletions src/think/route/dispatch/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
*/
class Controller extends Dispatch
{
/**
* 控制器分级
* @var string
*/
protected $layer;

/**
* 控制器名
* @var string
Expand Down Expand Up @@ -71,11 +77,12 @@ public function init(App $app)
}

$this->actionName = strip_tags($action);
$this->controller = strip_tags(($layer ? $layer . '.' : '') . $controller);
$this->controller = strip_tags($controller);
$this->layer = strip_tags($layer);

// 设置当前请求的控制器、操作
$this->request
->setLayer(strip_tags($layer))
->setLayer($this->layer)
->setController($this->controller)
->setAction($this->actionName);
}
Expand All @@ -84,7 +91,8 @@ public function exec()
{
try {
// 实例化控制器
$instance = $this->controller($this->controller);
$controller = ($this->layer ? $this->layer . '.' : '') . $this->controller;
$instance = $this->controller($controller);
} catch (ClassNotFoundException $e) {
throw new HttpException(404, 'controller not exists:' . $e->getClass());
}
Expand Down

0 comments on commit 5fa4125

Please sign in to comment.