Skip to content

Commit

Permalink
fix: 应用文件加载及注释
Browse files Browse the repository at this point in the history
  • Loading branch information
zoujingli committed Sep 1, 2024
1 parent a2e7318 commit 7497620
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion plugin/think-library/src/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function register()
{
// 动态加载全局配置
[$dir, $ext] = [$this->app->getBasePath(), $this->app->getConfigExt()];
ToolsExtend::findFilesYield($dir, static function (SplFileInfo $info) use ($ext) {
ToolsExtend::findFilesYield($dir, function (SplFileInfo $info) use ($ext) {
$info->getBasename() === "sys{$ext}" && include_once $info->getPathname();
});
if (is_file($file = "{$dir}common{$ext}")) include_once $file;
Expand Down
2 changes: 1 addition & 1 deletion plugin/think-library/src/extend/PhinxExtend.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ private function _create_{$table}() {
private static function nextFile(string $class): string
{
[$filename, $versions, $startVersion] = [Str::snake($class), [], 20009999999999];
ToolsExtend::findFilesYield(syspath('database/migrations'), static function (SplFileInfo $info) use ($class, $filename, &$versions) {
ToolsExtend::findFilesYield(syspath('database/migrations'), function (SplFileInfo $info) use ($class, $filename, &$versions) {
$bname = pathinfo($info->getBasename(), PATHINFO_FILENAME);
$versions[] = $version = intval(substr($bname, 0, 14));
if ($filename === substr($bname, 15) && unlink($info->getRealPath())) {
Expand Down
10 changes: 8 additions & 2 deletions plugin/think-library/src/support/middleware/MultAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,21 +166,27 @@ private function setMultiApp(string $appName, bool $appBind): bool
private function loadMultiApp(string $appPath): bool
{
[$ext, $fmaps] = [$this->app->getConfigExt(), []];
// 加载应用函数文件
if (is_file($file = "{$appPath}common{$ext}")) include_once $file;
ToolsExtend::findFilesYield($appPath . 'config', static function (SplFileInfo $info) use ($ext) {
if (strtolower(".{$info->getExtension()}") === "{$ext}") {
// 加载应用配置文件
ToolsExtend::findFilesYield($appPath . 'config', function (SplFileInfo $info) use ($ext) {
if (strtolower(".{$info->getExtension()}") === $ext) {
$this->app->config->load($info->getPathname(), $info->getBasename($ext));
}
});
// 加载应用路由配置
if (in_array('route', $fmaps) && method_exists($this->app->route, 'reload')) {
$this->app->route->reload();
}
// 加载应用映射配置
if (is_file($file = "{$appPath}provider{$ext}")) {
$this->app->bind(include $file);
}
// 加载应用事件配置
if (is_file($file = "{$appPath}event{$ext}")) {
$this->app->loadEvent(include $file);
}
// 加载应用中间键配置
if (is_file($file = "{$appPath}middleware{$ext}")) {
$this->app->middleware->import(include $file, 'app');
}
Expand Down

0 comments on commit 7497620

Please sign in to comment.