You've already forked Atomcms-edit
Modernize: remove unused deps, replace qirolab/laravel-themer with custom ThemeService, drop doctrine/dbal
- Remove whichbrowser/parser, mockery/mockery, fruitcake/laravel-debugbar,
itsgoingd/clockwork (all unused)
- Replace qirolab/laravel-themer (dev-master) with custom App\Services\ThemeService
and App\Providers\ThemeServiceProvider
- Drop doctrine/dbal: rewrite all ->change() calls in 8 migrations to raw
DB::statement('ALTER TABLE ... MODIFY ...') SQL
- RenameColumn() kept intact (works without dbal in Laravel 13)
- Fix 2026_04_04 migration: inverted column-exists logic corrected
- Clear bootstrap cache to remove stale references to removed packages
This commit is contained in:
@@ -2,21 +2,25 @@
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Services\ThemeService;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Qirolab\Theme\Theme;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class SetThemeMiddleware
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ThemeService $themeService,
|
||||
) {}
|
||||
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$theme = setting('theme');
|
||||
|
||||
if (empty($theme) || $theme === '1') {
|
||||
Theme::set('atom');
|
||||
$this->themeService->set('atom');
|
||||
} else {
|
||||
Theme::set($theme);
|
||||
$this->themeService->set($theme);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Services\ThemeService;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ThemeServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->singleton(ThemeService::class, fn () => new ThemeService);
|
||||
}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
if (config('theme.active')) {
|
||||
app(ThemeService::class)->set(
|
||||
config('theme.active'),
|
||||
config('theme.parent'),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
class ThemeService
|
||||
{
|
||||
private const string DEFAULT_THEME = 'atom';
|
||||
|
||||
private ?string $activeTheme = null;
|
||||
|
||||
private ?string $parentTheme = null;
|
||||
|
||||
public function set(string $theme, ?string $parentTheme = null): void
|
||||
{
|
||||
$this->clear();
|
||||
|
||||
$basePath = config('theme.base_path', base_path('resources/themes'));
|
||||
|
||||
if ($parentTheme) {
|
||||
View::addLocation("{$basePath}/{$parentTheme}/views");
|
||||
$this->parentTheme = $parentTheme;
|
||||
}
|
||||
|
||||
View::addLocation("{$basePath}/{$theme}/views");
|
||||
$this->activeTheme = $theme;
|
||||
|
||||
$this->registerVendorNamespaces($theme, $basePath);
|
||||
}
|
||||
|
||||
public function active(): ?string
|
||||
{
|
||||
return $this->activeTheme;
|
||||
}
|
||||
|
||||
public function parent(): ?string
|
||||
{
|
||||
return $this->parentTheme;
|
||||
}
|
||||
|
||||
public function resolve(?string $theme = null): string
|
||||
{
|
||||
return $theme ?? $this->activeTheme ?? self::DEFAULT_THEME;
|
||||
}
|
||||
|
||||
public function clear(): void
|
||||
{
|
||||
$this->activeTheme = null;
|
||||
$this->parentTheme = null;
|
||||
}
|
||||
|
||||
private function registerVendorNamespaces(string $theme, string $basePath): void
|
||||
{
|
||||
$vendorPath = "{$basePath}/{$theme}/views/vendor";
|
||||
|
||||
if (! is_dir($vendorPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$directories = scandir($vendorPath);
|
||||
|
||||
foreach ($directories as $namespace) {
|
||||
if ($namespace !== '.' && $namespace !== '..') {
|
||||
View::prependNamespace($namespace, "{$vendorPath}/{$namespace}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user