mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-14 19:40:53 +08:00
feat: plugin controller config system with guest_comm_config hook integration
- Add HasPluginConfig trait and PluginController base class - Integrate guest_comm_config hook in CommController for plugin frontend config injection - Add user creation functionality to UserService and fix null value handling - Enhance AbstractPlugin.getConfig() with key parameter support - Multiple service layer optimizations and architecture improvements
This commit is contained in:
@@ -58,9 +58,13 @@ abstract class AbstractPlugin
|
||||
/**
|
||||
* 获取配置
|
||||
*/
|
||||
public function getConfig(): array
|
||||
public function getConfig(?string $key = null, $default = null): mixed
|
||||
{
|
||||
return $this->config;
|
||||
$config = $this->config;
|
||||
if ($key) {
|
||||
$config = $config[$key] ?? $default;
|
||||
}
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,7 @@ class PluginManager
|
||||
*/
|
||||
public function getPluginPath(string $pluginCode): string
|
||||
{
|
||||
return $this->pluginPath . '/' . Str::studly($pluginCode);
|
||||
return $this->pluginPath . '/' . Str::studly($pluginCode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,16 +85,21 @@ class PluginManager
|
||||
{
|
||||
$routesPath = $this->getPluginPath($pluginCode) . '/routes';
|
||||
if (File::exists($routesPath)) {
|
||||
$files = ['web.php', 'api.php'];
|
||||
foreach ($files as $file) {
|
||||
$routeFile = $routesPath . '/' . $file;
|
||||
if (File::exists($routeFile)) {
|
||||
Route::middleware('web')
|
||||
->namespace($this->getPluginNamespace($pluginCode) . '\\Controllers')
|
||||
->group(function () use ($routeFile) {
|
||||
require $routeFile;
|
||||
});
|
||||
}
|
||||
$webRouteFile = $routesPath . '/web.php';
|
||||
$apiRouteFile = $routesPath . '/api.php';
|
||||
if (File::exists($webRouteFile)) {
|
||||
Route::middleware('web')
|
||||
->namespace($this->getPluginNamespace($pluginCode) . '\\Controllers')
|
||||
->group(function () use ($webRouteFile) {
|
||||
require $webRouteFile;
|
||||
});
|
||||
}
|
||||
if (File::exists($apiRouteFile)) {
|
||||
Route::middleware('api')
|
||||
->namespace($this->getPluginNamespace($pluginCode) . '\\Controllers')
|
||||
->group(function () use ($apiRouteFile) {
|
||||
require $apiRouteFile;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user