diff --git a/app/Providers/PluginServiceProvider.php b/app/Providers/PluginServiceProvider.php index a2adaf24..0e0487c4 100644 --- a/app/Providers/PluginServiceProvider.php +++ b/app/Providers/PluginServiceProvider.php @@ -15,34 +15,28 @@ class PluginServiceProvider extends ServiceProvider */ public function boot(PluginManager $plugins) { - $namespaces = []; + // store paths of class files of plugins + $src_paths = []; + + $loader = $this->app->make('translation.loader'); + // make view instead of view.finder since the finder is defined as not a singleton + $finder = $this->app->make('view'); foreach ($plugins->getPlugins() as $plugin) { - $namespaces[$plugin->getNameSpace()] = $plugin->getPath()."/src"; + $src_paths[$plugin->getNameSpace()] = $plugin->getPath()."/src"; + // add paths of translation files for namespace hints + $loader->addNamespace($plugin->getNameSpace(), $plugin->getPath()."/lang"); + // add paths of views + $finder->addNamespace($plugin->getNameSpace(), $plugin->getPath()."/views"); } - // register class autoloader for plugins - spl_autoload_register(function($class) use ($namespaces) { - // traverse in registered plugin namespaces - foreach ((array) array_keys($namespaces) as $namespace) { - if ($namespace != '' && mb_strpos($class, $namespace) === 0) { - // parse real file path - $path = $namespaces[$namespace].Str::replaceFirst($namespace, '', $class).".php"; - $path = str_replace('\\', '/', $path); - - if (file_exists($path)) { - include $path; - } - } - } - }); + $this->registerClassAutoloader($src_paths); $bootstrappers = $plugins->getEnabledBootstrappers(); foreach ($bootstrappers as $file) { - // bootstraper is a closure $bootstrapper = require $file; - + // call closure using service container $this->app->call($bootstrapper); } } @@ -56,4 +50,28 @@ class PluginServiceProvider extends ServiceProvider { $this->app->singleton('plugins', PluginManager::class); } + + /** + * Register class autoloader for plugins. + * + * @return void + */ + protected function registerClassAutoloader($paths) + { + spl_autoload_register(function ($class) use ($paths) { + // traverse in registered plugin paths + foreach ((array) array_keys($paths) as $namespace) { + if ($namespace != '' && mb_strpos($class, $namespace) === 0) { + // parse real file path + $path = $paths[$namespace].Str::replaceFirst($namespace, '', $class).".php"; + $path = str_replace('\\', '/', $path); + + if (file_exists($path)) { + // include class file if it exists + include $path; + } + } + } + }); + } } diff --git a/resources/lang/en/general.yml b/resources/lang/en/general.yml index 57fb2676..e5901729 100644 --- a/resources/lang/en/general.yml +++ b/resources/lang/en/general.yml @@ -15,7 +15,6 @@ dashboard: Dashboard my-closet: Closet player-manage: Player Manage user-manage: User Manage -generate-config: Generate Config plugin-manage: Plugin Manage customize: Customize options: Options diff --git a/resources/lang/en/user.yml b/resources/lang/en/user.yml index 3f46a04a..755ad569 100644 --- a/resources/lang/en/user.yml +++ b/resources/lang/en/user.yml @@ -144,11 +144,3 @@ profile: wrong-password: Wrong password. success: Your account is deleted successfully. - -config: - mod-requirement: MOD Requirement - mod-intro: | -

We support all versions of UniSkinMod and CustomSkinLoader, and any other skin mod using with leagcy links.

-

Detailed Documentation Here: @GitHub

- version: Version - config-file: Config File diff --git a/resources/lang/zh-CN/general.yml b/resources/lang/zh-CN/general.yml index 01172745..871b0925 100644 --- a/resources/lang/zh-CN/general.yml +++ b/resources/lang/zh-CN/general.yml @@ -15,7 +15,6 @@ dashboard: 仪表盘 my-closet: 我的衣柜 player-manage: 角色管理 user-manage: 用户管理 -generate-config: 配置生成 plugin-manage: 插件管理 customize: 个性化 options: 站点配置 diff --git a/resources/lang/zh-CN/user.yml b/resources/lang/zh-CN/user.yml index 636e1773..d934168f 100644 --- a/resources/lang/zh-CN/user.yml +++ b/resources/lang/zh-CN/user.yml @@ -151,11 +151,3 @@ profile: wrong-password: 密码错误 success: 账号已被成功删除 - -config: - mod-requirement: MOD 需求 - mod-intro: | -

本站支持的皮肤 MOD 有 UniSkinModCustomSkinLoader 各自的新版和旧版,以及任何支持传统皮肤加载链接的皮肤 MOD。

-

详细教程:@GitHub

- version: 版本 - config-file: 配置文件