From 2c349e0832c54049b506d3fccaa52264e983888e Mon Sep 17 00:00:00 2001 From: wuyanwen Date: Tue, 17 Dec 2019 09:02:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/CatchAdmin.php | 52 +++++++++++++---------------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/extend/catcher/CatchAdmin.php b/extend/catcher/CatchAdmin.php index 24faac1..73e6d82 100644 --- a/extend/catcher/CatchAdmin.php +++ b/extend/catcher/CatchAdmin.php @@ -18,15 +18,14 @@ class CatchAdmin } /** + * 创建目录 * - * @time 2019年12月04日 - * @param $module + * @time 2019年12月16日 + * @param string $directory * @return string */ - public static function moduleDirectory($module): string + public static function makeDirectory(string $directory): string { - $directory = self::directory() . $module . DIRECTORY_SEPARATOR; - if (!is_dir($directory) && !mkdir($directory, 0777, true) && !is_dir($directory)) { throw new \RuntimeException(sprintf('Directory "%s" was not created', $directory)); } @@ -34,6 +33,17 @@ class CatchAdmin return $directory; } + /** + * + * @time 2019年12月04日 + * @param $module + * @return string + */ + public static function moduleDirectory($module): string + { + return self::makeDirectory(self::directory() . $module . DIRECTORY_SEPARATOR); + } + /** * * @time 2019年11月30日 @@ -41,13 +51,7 @@ class CatchAdmin */ public static function cacheDirectory(): string { - $directory = app()->getRuntimePath() . self::NAME . DIRECTORY_SEPARATOR; - - if (!is_dir($directory) && !mkdir($directory, 0777, true) && !is_dir($directory)) { - throw new \RuntimeException(sprintf('Directory "%s" was not created', $directory)); - } - - return $directory; + return self::makeDirectory(app()->getRuntimePath() . self::NAME . DIRECTORY_SEPARATOR); } /** @@ -58,13 +62,7 @@ class CatchAdmin */ public static function backupDirectory(): string { - $directory = self::cacheDirectory() . 'backup' .DIRECTORY_SEPARATOR; - - if (!is_dir($directory) && !mkdir($directory, 0777, true) && !is_dir($directory)) { - throw new \RuntimeException(sprintf('Directory "%s" was not created', $directory)); - } - - return $directory; + return self::makeDirectory(self::cacheDirectory() . 'backup' .DIRECTORY_SEPARATOR); } /** @@ -98,13 +96,7 @@ class CatchAdmin */ public static function getModuleViewPath($module): string { - $directory = self::directory() . $module . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR; - - if (!is_dir($directory) && !mkdir($directory, 0777, true) && !is_dir($directory)) { - throw new \RuntimeException(sprintf('Directory "%s" was not created', $directory)); - } - - return $directory; + return self::makeDirectory(self::directory() . $module . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR); } /** @@ -115,13 +107,7 @@ class CatchAdmin */ public static function getModuleModelDirectory($module): string { - $directory = self::directory() . $module . DIRECTORY_SEPARATOR . 'model' . DIRECTORY_SEPARATOR; - - if (!is_dir($directory) && !mkdir($directory, 0777, true) && !is_dir($directory)) { - throw new \RuntimeException(sprintf('Directory "%s" was not created', $directory)); - } - - return $directory; + return self::makeDirectory(self::directory() . $module . DIRECTORY_SEPARATOR . 'model' . DIRECTORY_SEPARATOR); } /** *