- PluginManager: requires 依赖链校验(enable 需依赖已启用,disable 阻止有启用依赖者的插件,boot 跳过依赖未满足插件),all() 输出依赖状态供后台展示 - Plugins 页:卡片显示依赖链徽章,依赖未满足时禁用启用按钮,启停失败弹错误通知 - PostResource: form()/table() 增加 filament.post_form / filament.post_table 注入点 - membership 插件:注入「付费设置」Section(meta.price 单篇价格 + meta.members_only 会员专享)与表格价格/会员列
44 lines
995 B
PHP
44 lines
995 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
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);
|
|
|
|
if (! is_dir(config('plugins.path'))) {
|
|
return;
|
|
}
|
|
|
|
foreach ($manager->all() as $key => $plugin) {
|
|
if (! $plugin['enabled']) {
|
|
continue;
|
|
}
|
|
|
|
// 依赖未满足的插件跳过加载,避免运行时缺底层能力
|
|
if ($manager->dependencyProblems($key)) {
|
|
continue;
|
|
}
|
|
|
|
$provider = $manager->resolveProvider($key);
|
|
|
|
if ($provider && class_exists($provider)) {
|
|
$provider::bootPlugin($manager);
|
|
}
|
|
}
|
|
}
|
|
}
|