This commit is contained in:
2020-09-01 03:16:30 +08:00
parent 43434bec43
commit d7b926918a
+12 -13
View File
@@ -469,13 +469,9 @@ class Router extends Application implements RouterInterface
/** /**
* @throws * @throws
*/ */
public function loader() public function loadRouterSetting()
{ {
try { $this->loadRouteDir(APP_PATH . '/routes');
$this->loadDir(APP_PATH . '/routes');
} catch (Exception $exception) {
$this->error($exception->getMessage());
}
} }
/** /**
@@ -483,19 +479,22 @@ class Router extends Application implements RouterInterface
* @throws Exception * @throws Exception
* 加载目录下的路由文件 * 加载目录下的路由文件
*/ */
private function loadDir($path) private function loadRouteDir($path)
{ {
try {
$files = glob($path . '/*'); $files = glob($path . '/*');
for ($i = 0; $i < count($files); $i++) { for ($i = 0; $i < count($files); $i++) {
try {
if (is_dir($files[$i])) { if (is_dir($files[$i])) {
$this->loadDir($files[$i]); $this->loadRouteDir($files[$i]);
} else {
$this->loadFile($files[$i]);
}
} }
$this->loadRouteFile($files[$i]);
} catch (Exception $exception) { } catch (Exception $exception) {
$this->error($exception->getMessage()); $this->error($exception->getMessage());
} finally {
if (isset($exception)) {
unset($exception);
}
}
} }
} }
@@ -504,7 +503,7 @@ class Router extends Application implements RouterInterface
* @throws ReflectionException * @throws ReflectionException
* @throws Exception * @throws Exception
*/ */
private function loadFile($file) private function loadRouteFile($file)
{ {
$router = $this; $router = $this;