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

controller 方法增加获取多层控制器最后控制器名称 #2440

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
8 changes: 6 additions & 2 deletions src/think/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -1854,12 +1854,16 @@ public function setAction(string $action)
/**
* 获取当前的控制器名
* @access public
* @param bool $convert 转换为小写
* @param bool $convert 转换为小写
* @param bool $suffix 获取多层控制器最后控制器名称
* @return string
*/
public function controller(bool $convert = false): string
public function controller (bool $convert = false, bool $suffix = false): string
{
$name = $this->controller ?: '';
if ($suffix and $suffix_offset = strpos($name, '.')) {
$name = substr($name, $suffix_offset + 1);
}
return $convert ? strtolower($name) : $name;
}

Expand Down