33 lines
927 B
PHP
33 lines
927 B
PHP
<?php
|
|
|
|
namespace App\Support;
|
|
|
|
use Illuminate\Validation\ValidationException;
|
|
|
|
final class SiteProfile
|
|
{
|
|
public static function isHn(): bool
|
|
{
|
|
return config('site.profile', 'dpl') === 'hn';
|
|
}
|
|
|
|
public static function publicSettings(): array
|
|
{
|
|
return self::isHn() ? [
|
|
'frontend_theme' => config('site.theme', 'EZ'),
|
|
'app_name' => config('site.name'),
|
|
'logo' => config('site.logo'),
|
|
'app_description' => config('site.description'),
|
|
] : [];
|
|
}
|
|
|
|
public static function assertSettingsWritable(array $settings): void
|
|
{
|
|
foreach (self::publicSettings() as $key => $value) {
|
|
if (array_key_exists($key, $settings) && $settings[$key] !== $value) {
|
|
throw ValidationException::withMessages([$key => 'hn 品牌与主题由 SITE_PROFILE / SITE_* 部署配置管理。']);
|
|
}
|
|
}
|
|
}
|
|
}
|