Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持去除多层控制器默认前缀 #2599

Open
wants to merge 1 commit into
base: 6.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/think/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -1875,11 +1875,15 @@ public function setAction(string $action)
* 获取当前的控制器名
* @access public
* @param bool $convert 转换为小写
* @param bool $prefix 去除多层控制器前缀
* @return string
*/
public function controller(bool $convert = false): string
public function controller(bool $convert = false, bool $prefix = false): string
{
$name = $this->controller ?: '';
if ($prefix and strpos($name, '.')) {
$name = substr($name, strripos($name, '.') + 1);
}
return $convert ? strtolower($name) : $name;
}

Expand Down