mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-14 14:28:27 +08:00
Fix #17395: Fixed issues with actions that contain underscores in their names
This commit is contained in:

committed by
Alexander Makarov

parent
56f639358c
commit
2b9374558b
@ -212,7 +212,7 @@ class HelpController extends Controller
|
||||
foreach ($class->getMethods() as $method) {
|
||||
$name = $method->getName();
|
||||
if ($name !== 'actions' && $method->isPublic() && !$method->isStatic() && strncmp($name, 'action', 6) === 0) {
|
||||
$actions[] = Inflector::camel2id(substr($name, 6), '-', true);
|
||||
$actions[] = $this->camel2id(substr($name, 6));
|
||||
}
|
||||
}
|
||||
sort($actions);
|
||||
@ -557,4 +557,16 @@ class HelpController extends Controller
|
||||
{
|
||||
return "\nThis is Yii version " . \Yii::getVersion() . ".\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a CamelCase action name into an ID in lowercase.
|
||||
* Words in the ID are concatenated using the specified character '-'.
|
||||
* For example, 'CreateUser' will be converted to 'create-user'.
|
||||
* @param string $name the string to be converted
|
||||
* @return string the resulting ID
|
||||
*/
|
||||
private function camel2id($name)
|
||||
{
|
||||
return mb_strtolower(trim(preg_replace('/\p{Lu}/u', '-\0', $name), '-'), 'UTF-8');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user