added theme support

This commit is contained in:
Mark Gregory
2026-10-20 10:27:30 +01:00
parent f0e31aad6b
commit c5353d0351
6 changed files with 76 additions and 11 deletions
@@ -0,0 +1,65 @@
<?php
namespace Modules\Stylist\Services;
use App\Models\SiteSetting;
final class SiteSettingsRepository
{
/**
* Retrieve a SonarDesk site setting.
*
* The scope argument is retained for compatibility with Stylist.
*/
public function get(
string $key,
mixed $default = null,
string $scope = 'site'
): mixed {
$this->validateScope($scope);
$value = SiteSetting::valueFor($key);
return $value ?? $default;
}
/**
* Persist a SonarDesk site setting.
*
* The type and public arguments are retained for compatibility
* with Stylist's existing theme management API.
*/
public function put(
string $key,
mixed $value,
string $scope = 'site',
string $type = 'string',
bool $public = true
): void {
$this->validateScope($scope);
SiteSetting::put(
$key,
$value === null ? null : (string) $value
);
}
/**
* Return all site settings as an associative array.
*/
public function site(): array
{
return SiteSetting::query()
->pluck('value', 'key')
->all();
}
private function validateScope(string $scope): void
{
if ($scope !== 'site') {
throw new \InvalidArgumentException(
"Unsupported settings scope: {$scope}"
);
}
}
}
@@ -3,11 +3,11 @@
namespace Modules\Stylist\Services;
use Illuminate\Support\Facades\Auth;
use Modules\Settings\Services\SettingsRepository;
use Modules\Stylist\Services\SiteSettingsRepository;
final class TenantThemeResolver
{
public function __construct(private readonly SettingsRepository $settings) {}
public function __construct(private readonly SiteSettingsRepository $settings) {}
public function resolve(?string $context = null): string
{
@@ -6,13 +6,13 @@ use Illuminate\Filesystem\Filesystem;
use Illuminate\Http\UploadedFile;
use Modules\Stylist\Theme\Loader;
use Modules\Stylist\Theme\Theme;
use Modules\Settings\Services\SettingsRepository;
use Modules\Stylist\Services\SiteSettingsRepository;
use RuntimeException;
use ZipArchive;
final class ThemePackageManager
{
public function __construct(private readonly Filesystem $files, private readonly Loader $loader, private readonly ThemeValidator $validator, private readonly SettingsRepository $settings) {}
public function __construct(private readonly Filesystem $files, private readonly Loader $loader, private readonly ThemeValidator $validator, private readonly SiteSettingsRepository $settings) {}
public function install(UploadedFile $upload): Theme
{