一键生成CRUD兼容双驼峰形式的控制器名——

1、链接则需转为下划线与一键生成菜单保持一致
2、视图目录名则需转为下划线
pull/101/head
PPPSCN 2019-03-02 09:23:51 +08:00
parent 734c0c46a5
commit ad0f4fe08a
1 changed files with 4 additions and 3 deletions

View File

@ -359,11 +359,12 @@ class Crud extends Command
//验证器 //验证器
list($validateNamespace, $validateName, $validateFile, $validateArr) = $this->getValidateData($validateModuleName, $validate, $table); list($validateNamespace, $validateName, $validateFile, $validateArr) = $this->getValidateData($validateModuleName, $validate, $table);
$controllerUrl = strtolower(implode('/', $controllerArr)); //如果控制器名为双驼峰形式,链接则需转为下划线与一键生成菜单保持一致
$controllerUrl = strtolower(preg_replace('/(?<=[a-z])([A-Z])/', '_$1', implode('/', $controllerArr)));
$controllerBaseName = strtolower(implode(DS, $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'; $javascriptFile = ROOT_PATH . 'public' . DS . 'assets' . DS . 'js' . DS . 'backend' . DS . $controllerBaseName . '.js';