33 lines
956 B
PHP
33 lines
956 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
namespace App\Blog\Providers;
|
|
|
|
use App\Blog\Support\ThemeManager;
|
|
use App\Blog\View\Composers\SidebarComposer;
|
|
use Illuminate\Support\Facades\File;
|
|
use Illuminate\Support\Facades\View;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class ThemeServiceProvider extends ServiceProvider
|
|
{
|
|
public function register(): void
|
|
{
|
|
$this->app->singleton(ThemeManager::class);
|
|
}
|
|
|
|
public function boot(): void
|
|
{
|
|
// 激活主题的 views 目录前置到全局视图路径,实现主题覆盖 + 默认兜底
|
|
app(ThemeManager::class)->prependViews();
|
|
|
|
// 侧边栏数据共享:所有前台视图自动获得 $categories/$recentPosts/$hotTags/$links 等
|
|
View::composer(
|
|
['index', 'show', 'list', 'archives', 'tags', 'tag', 'search', 'links', 'comments', 'login', 'register', 'profile', 'membership.*', 'payments.*'],
|
|
SidebarComposer::class
|
|
);
|
|
}
|
|
}
|