完善Build类支持CLASS_APPEND_SUFFIX常量配置

This commit is contained in:
thinkphp
2016-02-25 20:13:48 +08:00
parent 1989acf8ef
commit 5c8db926a6
2 changed files with 11 additions and 10 deletions

View File

@@ -97,16 +97,17 @@ class Build
} else {
// 生成相关MVC文件
foreach ($file as $val) {
$filename = $modulePath . $path . DS . $val . EXT;
$filename = $modulePath . $path . DS . $val . (CLASS_APPEND_SUFFIX ? ucfirst($path) : '') . EXT;
$namespace = APP_NAMESPACE . '\\' . ($module ? $module . '\\' : '') . $path;
$class = $val . (CLASS_APPEND_SUFFIX ? ucfirst($path) : '');
switch ($path) {
case CONTROLLER_LAYER: // 控制器
$content = "<?php\nnamespace {$namespace};\n\nclass {$val}\n{\n\n}";
case CONTROLLER_LAYER: // 控制器
$content = "<?php\nnamespace {$namespace};\n\nclass {$class}\n{\n\n}";
break;
case MODEL_LAYER: // 模型
$content = "<?php\nnamespace {$namespace};\n\nuse think\Model;\n\nclass {$val} extends Model\n{\n\n}";
case MODEL_LAYER: // 模型
$content = "<?php\nnamespace {$namespace};\n\nuse think\Model;\n\nclass {$class} extends Model\n{\n\n}";
break;
case VIEW_LAYER: // 视图
case VIEW_LAYER: // 视图
$filename = $modulePath . $path . DS . $val . '.html';
if (!is_dir(dirname($filename))) {
// 创建目录
@@ -116,7 +117,7 @@ class Build
break;
default:
// 其他文件
$content = "<?php\nnamespace {$namespace};\n\nclass {$val}\n{\n\n}";
$content = "<?php\nnamespace {$namespace};\n\nclass {$class}\n{\n\n}";
}
if (!is_file($filename)) {
@@ -130,10 +131,10 @@ class Build
// 创建欢迎页面
protected static function buildHello($module)
{
$filename = APP_PATH . ($module ? $module . DS : '') . CONTROLLER_LAYER . DS . Config::get('default_controller') . EXT;
$filename = APP_PATH . ($module ? $module . DS : '') . CONTROLLER_LAYER . DS . Config::get('default_controller') . (CLASS_APPEND_SUFFIX ? ucfirst(CONTROLLER_LAYER) : '') . EXT;
if (!is_file($filename)) {
$content = file_get_contents(THINK_PATH . 'tpl' . DS . 'default_index.tpl');
$content = str_replace(['{$app}', '{$module}', '{layer}'], [APP_NAMESPACE, $module ? $module . '\\' : '', CONTROLLER_LAYER], $content);
$content = str_replace(['{$app}', '{$module}', '{layer}', '{$suffix}'], [APP_NAMESPACE, $module ? $module . '\\' : '', CONTROLLER_LAYER, CLASS_APPEND_SUFFIX ? ucfirst(CONTROLLER_LAYER) : ''], $content);
if (!is_dir(dirname($filename))) {
mkdir(dirname($filename), 0777, true);
}

View File

@@ -1,7 +1,7 @@
<?php
namespace {$app}\{$module}{layer};
class Index
class Index{$suffix}
{
public function index()
{