rename providers to service

This commit is contained in:
Vehikl 2025-06-05 16:01:25 -04:00
parent 4a89e75a09
commit 6e806d142e
18 changed files with 155 additions and 155 deletions

View File

@ -5,17 +5,17 @@ namespace App\Extensions\Avatar;
use App\Models\User;
use Illuminate\Support\Facades\Storage;
class AvatarProvider
class AvatarService
{
/** @var AvatarSchemaInterface[] */
private array $providers = [];
private array $schemas = [];
/**
* @return AvatarSchemaInterface[] | AvatarSchemaInterface | null
*/
public function get(?string $id = null): array|AvatarSchemaInterface|null
{
return $id ? array_get($this->providers, $id) : $this->providers;
return $id ? array_get($this->schemas, $id) : $this->schemas;
}
public function getActiveSchema(): ?AvatarSchemaInterface
@ -36,12 +36,12 @@ class AvatarProvider
return $this->getActiveSchema()?->get($user);
}
public function register(AvatarSchemaInterface $provider): void
public function register(AvatarSchemaInterface $schema): void
{
if (array_key_exists($provider->getId(), $this->providers)) {
if (array_key_exists($schema->getId(), $this->schemas)) {
return;
}
$this->providers[$provider->getId()] = $provider;
$this->schemas[$schema->getId()] = $schema;
}
}

View File

@ -6,7 +6,7 @@ use App\Extensions\Captcha\Schemas\CaptchaSchemaInterface;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
class CaptchaProvider
class CaptchaService
{
/** @var array<string, CaptchaSchemaInterface> */
private array $schemas = [];

View File

@ -2,7 +2,7 @@
namespace App\Extensions\Captcha\Schemas\Turnstile;
use App\Extensions\Captcha\CaptchaProvider;
use App\Extensions\Captcha\CaptchaService;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Support\Facades\App;
@ -11,7 +11,7 @@ class Rule implements ValidationRule
{
public function validate(string $attribute, mixed $value, Closure $fail): void
{
$response = App::call(fn (CaptchaProvider $provider) => $provider->getActiveSchema()->validateResponse($value));
$response = App::call(fn (CaptchaService $service) => $service->getActiveSchema()->validateResponse($value));
if (!$response['success']) {
$fail($response['message'] ?? 'Unknown error occurred, please try again');

View File

@ -2,10 +2,10 @@
namespace App\Extensions\Features;
class FeatureProvider
class FeatureService
{
/** @var FeatureSchemaInterface[] */
private array $providers = [];
private array $schemas = [];
/**
* @param string[]|string|null $id
@ -14,18 +14,18 @@ class FeatureProvider
public function get(array|string|null $id = null): array|FeatureSchemaInterface
{
if (is_array($id)) {
return collect($this->providers)->only($id)->all();
return collect($this->schemas)->only($id)->all();
}
return $id ? $this->providers[$id] : $this->providers;
return $id ? $this->schemas[$id] : $this->schemas;
}
public function register(FeatureSchemaInterface $provider): void
public function register(FeatureSchemaInterface $schema): void
{
if (array_key_exists($provider->getId(), $this->providers)) {
if (array_key_exists($schema->getId(), $this->schemas)) {
return;
}
$this->providers[$provider->getId()] = $provider;
$this->schemas[$schema->getId()] = $schema;
}
}

View File

@ -1,41 +0,0 @@
<?php
namespace App\Extensions\OAuth;
use Illuminate\Support\Facades\Event;
use SocialiteProviders\Manager\SocialiteWasCalled;
class OAuthProvider
{
/** @var OAuthSchemaInterface[] */
private array $providers = [];
/** @return OAuthSchemaInterface[] | OAuthSchemaInterface */
public function get(?string $id = null): array|OAuthSchemaInterface
{
return $id ? $this->providers[$id] : $this->providers;
}
/** @return OAuthSchemaInterface[] */
public function getEnabled(): array
{
return collect($this->providers)
->filter(fn (OAuthSchemaInterface $provider) => $provider->isEnabled())
->all();
}
public function register(OAuthSchemaInterface $provider): void
{
if (array_key_exists($provider->getId(), $this->providers)) {
return;
}
config()->set('services.' . $provider->getId(), array_merge($provider->getServiceConfig(), ['redirect' => '/auth/oauth/callback/' . $provider->getId()]));
if ($provider->getSocialiteProvider()) {
Event::listen(fn (SocialiteWasCalled $event) => $event->extendSocialite($provider->getId(), $provider->getSocialiteProvider()));
}
$this->providers[$provider->getId()] = $provider;
}
}

View File

@ -0,0 +1,41 @@
<?php
namespace App\Extensions\OAuth;
use Illuminate\Support\Facades\Event;
use SocialiteProviders\Manager\SocialiteWasCalled;
class OAuthService
{
/** @var OAuthSchemaInterface[] */
private array $schemas = [];
/** @return OAuthSchemaInterface[] | OAuthSchemaInterface */
public function get(?string $id = null): array|OAuthSchemaInterface
{
return $id ? $this->schemas[$id] : $this->schemas;
}
/** @return OAuthSchemaInterface[] */
public function getEnabled(): array
{
return collect($this->schemas)
->filter(fn (OAuthSchemaInterface $schema) => $schema->isEnabled())
->all();
}
public function register(OAuthSchemaInterface $schema): void
{
if (array_key_exists($schema->getId(), $this->schemas)) {
return;
}
config()->set('services.' . $schema->getId(), array_merge($schema->getServiceConfig(), ['redirect' => '/auth/oauth/callback/' . $schema->getId()]));
if ($schema->getSocialiteProvider()) {
Event::listen(fn (SocialiteWasCalled $event) => $event->extendSocialite($schema->getId(), $schema->getSocialiteProvider()));
}
$this->schemas[$schema->getId()] = $schema;
}
}

View File

@ -2,9 +2,9 @@
namespace App\Filament\Admin\Pages;
use App\Extensions\Avatar\AvatarProvider;
use App\Extensions\Captcha\CaptchaProvider;
use App\Extensions\OAuth\OAuthProvider;
use App\Extensions\Avatar\AvatarService;
use App\Extensions\Captcha\CaptchaService;
use App\Extensions\OAuth\OAuthService;
use App\Models\Backup;
use App\Notifications\MailTested;
use App\Traits\EnvironmentWriterTrait;
@ -52,11 +52,11 @@ class Settings extends Page implements HasForms
protected static string $view = 'filament.pages.settings';
protected OAuthProvider $oauthProvider;
protected OAuthService $oauthService;
protected AvatarProvider $avatarProvider;
protected AvatarService $avatarService;
protected CaptchaProvider $captchaProvider;
protected CaptchaService $captchaService;
/** @var array<mixed>|null */
public ?array $data = [];
@ -66,11 +66,11 @@ class Settings extends Page implements HasForms
$this->form->fill();
}
public function boot(OAuthProvider $oauthProvider, AvatarProvider $avatarProvider, CaptchaProvider $captchaProvider): void
public function boot(OAuthService $oauthService, AvatarService $avatarService, CaptchaService $captchaService): void
{
$this->oauthProvider = $oauthProvider;
$this->avatarProvider = $avatarProvider;
$this->captchaProvider = $captchaProvider;
$this->oauthService = $oauthService;
$this->avatarService = $avatarService;
$this->captchaService = $captchaService;
}
public static function canAccess(): bool
@ -180,7 +180,7 @@ class Settings extends Page implements HasForms
Select::make('FILAMENT_AVATAR_PROVIDER')
->label(trans('admin/setting.general.avatar_provider'))
->native(false)
->options(collect($this->avatarProvider->get())->mapWithKeys(fn ($provider) => [$provider->getId() => $provider->getName()]))
->options(collect($this->avatarService->get())->mapWithKeys(fn ($schema) => [$schema->getId() => $schema->getName()]))
->selectablePlaceholder(false)
->default(env('FILAMENT_AVATAR_PROVIDER', config('panel.filament.avatar-provider'))),
Toggle::make('FILAMENT_UPLOADABLE_AVATARS')
@ -271,14 +271,14 @@ class Settings extends Page implements HasForms
{
$formFields = [];
$captchaSchemas = $this->captchaProvider->get();
foreach ($captchaSchemas as $captchaSchema) {
$id = Str::upper($captchaSchema->getId());
$captchaSchemas = $this->captchaService->get();
foreach ($captchaSchemas as $schema) {
$id = Str::upper($schema->getId());
$formFields[] = Section::make($captchaSchema->getName())
$formFields[] = Section::make($schema->getName())
->columns(5)
->icon($captchaSchema->getIcon() ?? 'tabler-shield')
->collapsed(fn () => !$captchaSchema->isEnabled())
->icon($schema->getIcon() ?? 'tabler-shield')
->collapsed(fn () => !$schema->isEnabled())
->collapsible()
->schema([
Hidden::make("CAPTCHA_{$id}_ENABLED")
@ -296,7 +296,7 @@ class Settings extends Page implements HasForms
->color('success')
->action(fn (Set $set) => $set("CAPTCHA_{$id}_ENABLED", true)),
])->columnSpan(1),
Group::make($captchaSchema->getSettingsForm())
Group::make($schema->getSettingsForm())
->visible(fn (Get $get) => $get("CAPTCHA_{$id}_ENABLED"))
->columns(4)
->columnSpan(4),
@ -532,14 +532,14 @@ class Settings extends Page implements HasForms
{
$formFields = [];
$oauthProviders = $this->oauthProvider->get();
foreach ($oauthProviders as $oauthProvider) {
$id = Str::upper($oauthProvider->getId());
$name = Str::title($oauthProvider->getId());
$oauthSchemas = $this->oauthService->get();
foreach ($oauthSchemas as $schema) {
$id = Str::upper($schema->getId());
$name = Str::title($schema->getId());
$formFields[] = Section::make($name)
->columns(5)
->icon($oauthProvider->getIcon() ?? 'tabler-brand-oauth')
->icon($schema->getIcon() ?? 'tabler-brand-oauth')
->collapsed(fn () => !env("OAUTH_{$id}_ENABLED", false))
->collapsible()
->schema([
@ -558,7 +558,7 @@ class Settings extends Page implements HasForms
->visible(fn (Get $get) => !$get("OAUTH_{$id}_ENABLED"))
->label(trans('admin/setting.oauth.enable'))
->color('success')
->steps($oauthProvider->getSetupSteps())
->steps($schema->getSetupSteps())
->modalHeading(trans('admin/setting.oauth.enable') . ' ' . $name)
->modalSubmitActionLabel(trans('admin/setting.oauth.enable'))
->modalCancelAction(false)
@ -572,7 +572,7 @@ class Settings extends Page implements HasForms
}
}),
])->columnSpan(1),
Group::make($oauthProvider->getSettingsForm())
Group::make($schema->getSettingsForm())
->visible(fn (Get $get) => $get("OAUTH_{$id}_ENABLED"))
->columns(4)
->columnSpan(4),

View File

@ -3,7 +3,7 @@
namespace App\Filament\Pages\Auth;
use App\Exceptions\Service\User\TwoFactorAuthenticationTokenInvalid;
use App\Extensions\OAuth\OAuthProvider;
use App\Extensions\OAuth\OAuthService;
use App\Facades\Activity;
use App\Models\ActivityLog;
use App\Models\ApiKey;
@ -52,12 +52,12 @@ class EditProfile extends BaseEditProfile
{
private ToggleTwoFactorService $toggleTwoFactorService;
protected OAuthProvider $oauthProvider;
protected OAuthService $oauthService;
public function boot(ToggleTwoFactorService $toggleTwoFactorService, OAuthProvider $oauthProvider): void
public function boot(ToggleTwoFactorService $toggleTwoFactorService, OAuthService $oauthService): void
{
$this->toggleTwoFactorService = $toggleTwoFactorService;
$this->oauthProvider = $oauthProvider;
$this->oauthService = $oauthService;
}
public function getMaxWidth(): MaxWidth|string
@ -67,7 +67,7 @@ class EditProfile extends BaseEditProfile
protected function getForms(): array
{
$oauthProviders = $this->oauthProvider->getEnabled();
$oauthSchemas = $this->oauthService->getEnabled();
return [
'form' => $this->form(
@ -150,21 +150,21 @@ class EditProfile extends BaseEditProfile
Tab::make(trans('profile.tabs.oauth'))
->icon('tabler-brand-oauth')
->visible(count($oauthProviders) > 0)
->schema(function () use ($oauthProviders) {
->visible(count($oauthSchemas) > 0)
->schema(function () use ($oauthSchemas) {
$actions = [];
foreach ($oauthProviders as $oauthProvider) {
foreach ($oauthSchemas as $schema) {
$id = $oauthProvider->getId();
$name = $oauthProvider->getName();
$id = $schema->getId();
$name = $schema->getName();
$unlink = array_key_exists($id, $this->getUser()->oauth ?? []);
$actions[] = Action::make("oauth_$id")
->label(($unlink ? trans('profile.unlink') : trans('profile.link')) . $name)
->icon($unlink ? 'tabler-unlink' : 'tabler-link')
->color(Color::hex($oauthProvider->getHexColor()))
->color(Color::hex($schema->getHexColor()))
->action(function (UserUpdateService $updateService) use ($id, $name, $unlink) {
if ($unlink) {
$oauth = auth()->user()->oauth;

View File

@ -3,8 +3,8 @@
namespace App\Filament\Pages\Auth;
use App\Events\Auth\ProvidedAuthenticationToken;
use App\Extensions\Captcha\CaptchaProvider;
use App\Extensions\OAuth\OAuthProvider;
use App\Extensions\Captcha\CaptchaService;
use App\Extensions\OAuth\OAuthService;
use App\Facades\Activity;
use App\Models\User;
use Filament\Facades\Filament;
@ -27,15 +27,15 @@ class Login extends BaseLogin
public bool $verifyTwoFactor = false;
protected OAuthProvider $oauthProvider;
protected OAuthService $oauthService;
protected CaptchaProvider $captchaProvider;
protected CaptchaService $captchaService;
public function boot(Google2FA $google2FA, OAuthProvider $oauthProvider, CaptchaProvider $captchaProvider): void
public function boot(Google2FA $google2FA, OAuthService $oauthService, CaptchaService $captchaService): void
{
$this->google2FA = $google2FA;
$this->oauthProvider = $oauthProvider;
$this->captchaProvider = $captchaProvider;
$this->oauthService = $oauthService;
$this->captchaService = $captchaService;
}
public function authenticate(): ?LoginResponse
@ -122,8 +122,8 @@ class Login extends BaseLogin
$this->getTwoFactorAuthenticationComponent(),
];
if ($captchaProvider = $this->getCaptchaComponent()) {
$schema = array_merge($schema, [$captchaProvider]);
if ($captchaComponent = $this->getCaptchaComponent()) {
$schema = array_merge($schema, [$captchaComponent]);
}
return [
@ -148,7 +148,7 @@ class Login extends BaseLogin
private function getCaptchaComponent(): ?Component
{
return $this->captchaProvider->getActiveSchema()?->getFormComponent();
return $this->captchaService->getActiveSchema()?->getFormComponent();
}
protected function throwFailureValidationException(): never
@ -174,16 +174,16 @@ class Login extends BaseLogin
{
$actions = [];
$oauthProviders = $this->oauthProvider->getEnabled();
$oauthSchemas = $this->oauthService->getEnabled();
foreach ($oauthProviders as $oauthProvider) {
foreach ($oauthSchemas as $schema) {
$id = $oauthProvider->getId();
$id = $schema->getId();
$actions[] = Action::make("oauth_$id")
->label($oauthProvider->getName())
->icon($oauthProvider->getIcon())
->color(Color::hex($oauthProvider->getHexColor()))
->label($schema->getName())
->icon($schema->getIcon())
->color(Color::hex($schema->getHexColor()))
->url(route('auth.oauth.redirect', ['driver' => $id], false));
}

View File

@ -5,7 +5,7 @@ namespace App\Filament\Server\Pages;
use App\Enums\ConsoleWidgetPosition;
use App\Enums\ContainerStatus;
use App\Exceptions\Http\Server\ServerStateConflictException;
use App\Extensions\Features\FeatureProvider;
use App\Extensions\Features\FeatureService;
use App\Filament\Server\Widgets\ServerConsole;
use App\Filament\Server\Widgets\ServerCpuChart;
use App\Filament\Server\Widgets\ServerMemoryChart;
@ -37,7 +37,7 @@ class Console extends Page
public ContainerStatus $status = ContainerStatus::Offline;
protected FeatureProvider $featureProvider;
protected FeatureService $featureService;
public function mount(): void
{
@ -55,12 +55,12 @@ class Console extends Page
}
}
public function boot(FeatureProvider $featureProvider): void
public function boot(FeatureService $featureService): void
{
$this->featureProvider = $featureProvider;
$this->featureService = $featureService;
/** @var Server $server */
$server = Filament::getTenant();
foreach ($featureProvider->get($server->egg->features) as $feature) {
foreach ($featureService->get($server->egg->features) as $feature) {
$this->cacheAction($feature->getAction());
}
}
@ -71,7 +71,7 @@ class Console extends Page
$data = json_decode($data);
$feature = data_get($data, 'key');
$feature = $this->featureProvider->get($feature);
$feature = $this->featureService->get($feature);
if ($this->getMountedAction()) {
return;
}

View File

@ -2,7 +2,7 @@
namespace App\Http\Controllers\Auth;
use App\Extensions\OAuth\OAuthProvider;
use App\Extensions\OAuth\OAuthService;
use App\Filament\Pages\Auth\EditProfile;
use App\Http\Controllers\Controller;
use App\Models\User;
@ -19,7 +19,7 @@ class OAuthController extends Controller
public function __construct(
private readonly AuthManager $auth,
private readonly UserUpdateService $updateService,
private readonly OAuthProvider $oauthProvider
private readonly OAuthService $oauthService
) {}
/**
@ -28,7 +28,7 @@ class OAuthController extends Controller
public function redirect(string $driver): RedirectResponse
{
// Driver is disabled - redirect to normal login
if (!$this->oauthProvider->get($driver)->isEnabled()) {
if (!$this->oauthService->get($driver)->isEnabled()) {
return redirect()->route('auth.login');
}
@ -41,7 +41,7 @@ class OAuthController extends Controller
public function callback(Request $request, string $driver): RedirectResponse
{
// Driver is disabled - redirect to normal login
if (!$this->oauthProvider->get($driver)->isEnabled()) {
if (!$this->oauthService->get($driver)->isEnabled()) {
return redirect()->route('auth.login');
}

View File

@ -2,7 +2,7 @@
namespace App\Http\Middleware;
use App\Extensions\Captcha\CaptchaProvider;
use App\Extensions\Captcha\CaptchaService;
use Closure;
use Illuminate\Foundation\Application;
use Illuminate\Http\Request;
@ -14,13 +14,13 @@ readonly class VerifyCaptcha
{
public function __construct(private Application $app) {}
public function handle(Request $request, Closure $next, CaptchaProvider $captchaProvider): mixed
public function handle(Request $request, Closure $next, CaptchaService $captchaService): mixed
{
if ($this->app->isLocal()) {
return $next($request);
}
$schemas = $captchaProvider->getActiveSchemas();
$schemas = $captchaService->getActiveSchemas();
foreach ($schemas as $schema) {
$response = $schema->validateResponse();

View File

@ -4,7 +4,7 @@ namespace App\Models;
use App\Contracts\Validatable;
use App\Exceptions\DisplayException;
use App\Extensions\Avatar\AvatarProvider;
use App\Extensions\Avatar\AvatarService;
use App\Rules\Username;
use App\Traits\HasValidation;
use DateTimeZone;
@ -396,8 +396,8 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
public function getFilamentAvatarUrl(): ?string
{
return App::call(function (AvatarProvider $provider) {
return $provider->getAvatarUrl($this);
return App::call(function (AvatarService $service) {
return $service->getAvatarUrl($this);
});
}

View File

@ -2,7 +2,7 @@
namespace App\Providers\Extensions;
use App\Extensions\Avatar\AvatarProvider;
use App\Extensions\Avatar\AvatarService;
use App\Extensions\Avatar\Schemas\GravatarSchema;
use App\Extensions\Avatar\Schemas\UiAvatarsSchema;
use Illuminate\Support\ServiceProvider;
@ -11,14 +11,14 @@ class AvatarServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->app->singleton(AvatarProvider::class, function ($app) {
$provider = new AvatarProvider();
$this->app->singleton(AvatarService::class, function ($app) {
$service = new AvatarService();
// Default Avatar providers
$provider->register(new GravatarSchema());
$provider->register(new UiAvatarsSchema());
$service->register(new GravatarSchema());
$service->register(new UiAvatarsSchema());
return $provider;
return $service;
});
}
}

View File

@ -2,7 +2,7 @@
namespace App\Providers\Extensions;
use App\Extensions\Captcha\CaptchaProvider;
use App\Extensions\Captcha\CaptchaService;
use App\Extensions\Captcha\Schemas\Turnstile\TurnstileSchema;
use Illuminate\Support\ServiceProvider;
@ -10,8 +10,8 @@ class CaptchaServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->app->singleton(CaptchaProvider::class, function ($app) {
$service = new CaptchaProvider();
$this->app->singleton(CaptchaService::class, function ($app) {
$service = new CaptchaService();
// Default Captcha providers
$service->register(new TurnstileSchema());

View File

@ -2,7 +2,7 @@
namespace App\Providers\Extensions;
use App\Extensions\Features\FeatureProvider;
use App\Extensions\Features\FeatureService;
use App\Extensions\Features\Schemas\GSLTokenSchema;
use App\Extensions\Features\Schemas\JavaVersionSchema;
use App\Extensions\Features\Schemas\MinecraftEulaSchema;
@ -14,8 +14,8 @@ class FeatureServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->app->singleton(FeatureProvider::class, function ($app) {
$provider = new FeatureProvider();
$this->app->singleton(FeatureService::class, function ($app) {
$provider = new FeatureService();
$provider->register(new GSLTokenSchema());
$provider->register(new JavaVersionSchema());

View File

@ -2,7 +2,7 @@
namespace App\Providers\Extensions;
use App\Extensions\OAuth\OAuthProvider;
use App\Extensions\OAuth\OAuthService;
use App\Extensions\OAuth\Schemas\AuthentikSchema;
use App\Extensions\OAuth\Schemas\CommonSchema;
use App\Extensions\OAuth\Schemas\DiscordSchema;
@ -15,24 +15,24 @@ class OAuthServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->app->singleton(OAuthProvider::class, function ($app) {
$provider = new OAuthProvider();
$this->app->singleton(OAuthService::class, function ($app) {
$service = new OAuthService();
// Default OAuth providers included with Socialite
$provider->register(new CommonSchema('facebook', 'tabler-brand-facebook-f', '#1877f2'));
$provider->register(new CommonSchema('x', 'tabler-brand-x-f', '#1da1f2'));
$provider->register(new CommonSchema('linkedin', 'tabler-brand-linkedin-f', '#0a66c2'));
$provider->register(new CommonSchema('google', 'tabler-brand-google-f', '#4285f4'));
$provider->register(new GithubSchema());
$provider->register(new GitlabSchema());
$provider->register(new CommonSchema('bitbucket', 'tabler-brand-bitbucket-f', '#205081'));
$provider->register(new CommonSchema('slack', 'tabler-brand-slack', '#6ecadc'));
$service->register(new CommonSchema('facebook', 'tabler-brand-facebook-f', '#1877f2'));
$service->register(new CommonSchema('x', 'tabler-brand-x-f', '#1da1f2'));
$service->register(new CommonSchema('linkedin', 'tabler-brand-linkedin-f', '#0a66c2'));
$service->register(new CommonSchema('google', 'tabler-brand-google-f', '#4285f4'));
$service->register(new GithubSchema());
$service->register(new GitlabSchema());
$service->register(new CommonSchema('bitbucket', 'tabler-brand-bitbucket-f', '#205081'));
$service->register(new CommonSchema('slack', 'tabler-brand-slack', '#6ecadc'));
// Additional OAuth providers from socialiteproviders.com
$provider->register(new AuthentikSchema());
$provider->register(new DiscordSchema());
$provider->register(new SteamSchema());
$service->register(new AuthentikSchema());
$service->register(new DiscordSchema());
$service->register(new SteamSchema());
return $provider;
return $service;
});
}
}

View File

@ -2,7 +2,7 @@
namespace App\Services\Servers;
use App\Extensions\Features\FeatureProvider;
use App\Extensions\Features\FeatureService;
use App\Extensions\Features\FeatureSchemaInterface;
use App\Models\Egg;
use App\Models\Mount;
@ -10,7 +10,7 @@ use App\Models\Server;
class ServerConfigurationStructureService
{
public function __construct(private EnvironmentService $environment, private FeatureProvider $provider) {}
public function __construct(private EnvironmentService $environment, private FeatureService $featureService) {}
/**
* Return a configuration array for a specific server when passed a server model.
@ -104,7 +104,7 @@ class ServerConfigurationStructureService
'egg' => [
'id' => $server->egg->uuid,
'file_denylist' => $server->egg->inherit_file_denylist,
'features' => collect($this->provider->get($server->egg->features))->mapWithKeys(fn (FeatureSchemaInterface $feature) => [
'features' => collect($this->featureService->get($server->egg->features))->mapWithKeys(fn (FeatureSchemaInterface $feature) => [
$feature->getId() => $feature->getListeners(),
])->all(),
],