M4: 插件框架(钩子系统/ZIP安装/市场客户端)+ blog-seo 插件(JSON-LD/OG/llms.txt/Markdown导出)+ 后台插件/主题管理页
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Blog\Providers;
|
||||
|
||||
use App\Blog\Support\PluginManager;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class PluginManagerServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->singleton(PluginManager::class);
|
||||
}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
$manager = $this->app->make(PluginManager::class);
|
||||
|
||||
// 迁移尚未执行(migrate:fresh 首轮)时跳过,避免查询不存在的表
|
||||
if (! \Illuminate\Support\Facades\Schema::hasTable('plugin_records')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! is_dir(config('plugins.path'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($manager->all() as $key => $plugin) {
|
||||
if (! $plugin['enabled']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$provider = $manager->resolveProvider($key);
|
||||
|
||||
if ($provider && class_exists($provider)) {
|
||||
$provider::bootPlugin($manager);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user