优化CRUD视图文件 -- 如果控制器名字为驼峰形式,目录名需要转为下划线

pull/98/head
PPPSCN 2019-02-16 19:54:01 +08:00
parent 3079e5351f
commit 71617c2526
1 changed files with 4 additions and 2 deletions

View File

@ -330,8 +330,8 @@ class Crud extends Command
$controllerUrl = strtolower(implode('/', $controllerArr));
$controllerBaseName = strtolower(implode(DS, $controllerArr));
//视图文件
$viewDir = $adminPath . 'view' . DS . $controllerBaseName . DS;
//视图文件 -- 如果控制器名字为驼峰形式,目录名需要转为下划线
$viewDir = $adminPath . 'view' . DS . strtolower(preg_replace('/(?<=[a-z])([A-Z])/', '_$1', implode(DS, $controllerArr))) . DS;
//最终将生成的文件路径
$javascriptFile = ROOT_PATH . 'public' . DS . 'assets' . DS . 'js' . DS . 'backend' . DS . $controllerBaseName . '.js';
@ -753,6 +753,7 @@ class Crud extends Command
//表注释
$tableComment = $modelTableInfo['Comment'];
$tableCNName = mb_substr($tableComment, -1) == '表' ? mb_substr($tableComment, 0, -1) : $tableComment;
$tableComment = mb_substr($tableComment, -1) == '表' ? mb_substr($tableComment, 0, -1) . '管理' : $tableComment;
$modelInit = '';
@ -774,6 +775,7 @@ class Crud extends Command
'modelTableTypeName' => $modelTableTypeName,
'validateName' => $validateName,
'tableComment' => $tableComment,
'tableCNName' => $tableCNName,
'iconName' => $iconName,
'pk' => $priKey,
'order' => $order,