themes how part of site settings

This commit is contained in:
Mark Gregory
2026-07-28 12:43:19 +01:00
parent eafc5e8063
commit f834328044
12 changed files with 144 additions and 18 deletions
+15 -3
View File
@@ -10,13 +10,15 @@ final class Stylist
{
public function __construct(private readonly Loader $loader, private readonly TenantThemeResolver $resolver, private readonly ThemeSettings $settings) {}
public function current(): Theme
public function current(?string $context = null): Theme
{
$requested = $this->resolver->resolve();
$requested = $this->resolver->resolve($context);
try {
return $this->loader->find($requested);
} catch (ThemeNotFoundException) {
$fallback = (string) config('stylist.default_theme', 'default');
$fallback = $context === 'frontend'
? (string) config('stylist.default_frontend_theme', 'saasland')
: (string) config('stylist.default_backend_theme', config('stylist.default_theme', 'admin'));
if ($requested !== $fallback) {
return $this->loader->find($fallback);
}
@@ -24,6 +26,16 @@ final class Stylist
}
}
public function frontend(): Theme
{
return $this->current('frontend');
}
public function backend(): Theme
{
return $this->current('backend');
}
public function variables(): array
{
$theme = $this->current();