From e254999245a880baa584ca1ba043d1bf1d5014b1 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 1 Apr 2016 20:05:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84Build=E7=B1=BB=20=E5=BC=80?= =?UTF-8?q?=E6=94=BEmodule=E5=88=9B=E5=BB=BA=E6=A8=A1=E5=9D=97=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E4=B8=BA=E5=85=AC=E5=85=B1=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Build.php | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/library/think/Build.php b/library/think/Build.php index 5b7306cf..e0982561 100644 --- a/library/think/Build.php +++ b/library/think/Build.php @@ -12,7 +12,8 @@ namespace think; class Build { - public static function run($build) + // 根据传入的build资料创建目录和文件 + public static function run($build = []) { // 锁定 $lockfile = APP_PATH . 'build.lock'; @@ -30,7 +31,7 @@ class Build self::buildFile($list); } else { // 创建模块 - self::buildModule($module, $list); + self::module($module, $list); } } // 解除锁定 @@ -63,7 +64,7 @@ class Build } // 创建模块 - protected static function buildModule($module, $list) + public static function module($module = '', $list = []) { $module = APP_MULTI_MODULE ? $module : ''; if (!is_dir(APP_PATH . $module)) { @@ -76,6 +77,13 @@ class Build // 创建模块的默认页面 self::buildHello($module); } + if (empty($list)) { + // 创建默认的模块目录和文件 + $list = [ + '__file__' => ['config.php', 'common.php'], + '__dir__' => ['controller', 'model', 'view'], + ]; + } // 创建子目录和文件 foreach ($list as $path => $file) { $modulePath = APP_PATH . $module . DS; @@ -101,13 +109,13 @@ class Build $namespace = APP_NAMESPACE . '\\' . ($module ? $module . '\\' : '') . $path; $class = $val . (CLASS_APPEND_SUFFIX ? ucfirst($path) : ''); switch ($path) { - case CONTROLLER_LAYER: // 控制器 + case CONTROLLER_LAYER: // 控制器 $content = "