themes how part of site settings
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user