模块目录默认只生成config.php文件 其他的需要指定生成

This commit is contained in:
thinkphp
2015-12-11 09:35:52 +08:00
parent b34d2f3a1b
commit 78d5bbd471

View File

@@ -60,7 +60,7 @@ class Create
mkdir(APP_PATH . dirname($file), 0777, true);
}
if (!is_file(APP_PATH . $file)) {
file_put_contents(APP_PATH . $file, '');
file_put_contents(APP_PATH . $file, 'php' == pathinfo($file, PATHINFO_EXTENSION) ? "<?php\n" : '');
}
}
}
@@ -94,7 +94,7 @@ class Create
// 生成(空白)文件
foreach ($file as $name) {
if (!is_file($modulePath . $name)) {
file_put_contents($modulePath . $name, '');
file_put_contents($modulePath . $name, 'php' == pathinfo($name, PATHINFO_EXTENSION) ? "<?php\n" : '');
}
}
} else {
@@ -102,13 +102,13 @@ class Create
foreach ($file as $val) {
$filename = $modulePath . $path . DS . Loader::parseName($val) . EXT;
switch ($path) {
case CONTROLLER_LAYER: // 控制器
case CONTROLLER_LAYER: // 控制器
$content = "<?php\nnamespace {$module}\\{$path};\n\nclass {$val} {\n\n}";
break;
case MODEL_LAYER: // 模型
case MODEL_LAYER: // 模型
$content = "<?php\nnamespace {$module}\\{$path};\n\nclass {$val} extends \Think\Model{\n\n}";
break;
case VIEW_LAYER: // 视图
case VIEW_LAYER: // 视图
$filename = $modulePath . $path . DS . Loader::parseName($val) . '.html';
if (!is_dir(dirname($filename))) {
// 创建目录
@@ -146,14 +146,8 @@ class Create
// 创建模块公共文件
protected static function buildCommon($module)
{
if (!is_file(APP_PATH . $module . DS . 'common.php')) {
file_put_contents(APP_PATH . $module . DS . 'common.php', "<?php\n");
}
if (!is_file(APP_PATH . $module . DS . 'config.php')) {
file_put_contents(APP_PATH . $module . DS . 'config.php', "<?php\nreturn [\n\n];");
}
if (!is_file(APP_PATH . $module . DS . 'alias.php')) {
file_put_contents(APP_PATH . $module . DS . 'alias.php', "<?php\nreturn [\n\n];");
}
}
}