Replace server variable repository
This commit is contained in:
parent
860b2d890b
commit
7d8eba1595
5 changed files with 6 additions and 36 deletions
|
@ -1,7 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Pterodactyl\Contracts\Repository;
|
|
||||||
|
|
||||||
interface ServerVariableRepositoryInterface extends RepositoryInterface
|
|
||||||
{
|
|
||||||
}
|
|
|
@ -4,8 +4,8 @@ namespace Pterodactyl\Http\Controllers\Api\Client\Servers;
|
||||||
|
|
||||||
use Pterodactyl\Models\Server;
|
use Pterodactyl\Models\Server;
|
||||||
use Pterodactyl\Facades\Activity;
|
use Pterodactyl\Facades\Activity;
|
||||||
|
use Pterodactyl\Models\ServerVariable;
|
||||||
use Pterodactyl\Services\Servers\StartupCommandService;
|
use Pterodactyl\Services\Servers\StartupCommandService;
|
||||||
use Pterodactyl\Repositories\Eloquent\ServerVariableRepository;
|
|
||||||
use Pterodactyl\Transformers\Api\Client\EggVariableTransformer;
|
use Pterodactyl\Transformers\Api\Client\EggVariableTransformer;
|
||||||
use Pterodactyl\Http\Controllers\Api\Client\ClientApiController;
|
use Pterodactyl\Http\Controllers\Api\Client\ClientApiController;
|
||||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
|
@ -17,10 +17,8 @@ class StartupController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* StartupController constructor.
|
* StartupController constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(private StartupCommandService $startupCommandService)
|
||||||
private StartupCommandService $startupCommandService,
|
{
|
||||||
private ServerVariableRepository $repository
|
|
||||||
) {
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +63,7 @@ class StartupController extends ClientApiController
|
||||||
// Revalidate the variable value using the egg variable specific validation rules for it.
|
// Revalidate the variable value using the egg variable specific validation rules for it.
|
||||||
$this->validate($request, ['value' => $variable->rules]);
|
$this->validate($request, ['value' => $variable->rules]);
|
||||||
|
|
||||||
$this->repository->updateOrCreate([
|
ServerVariable::query()->updateOrCreate([
|
||||||
'server_id' => $server->id,
|
'server_id' => $server->id,
|
||||||
'variable_id' => $variable->id,
|
'variable_id' => $variable->id,
|
||||||
], [
|
], [
|
||||||
|
|
|
@ -26,7 +26,6 @@ use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
||||||
use Pterodactyl\Repositories\Eloquent\DatabaseHostRepository;
|
use Pterodactyl\Repositories\Eloquent\DatabaseHostRepository;
|
||||||
use Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface;
|
use Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface;
|
||||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||||
use Pterodactyl\Repositories\Eloquent\ServerVariableRepository;
|
|
||||||
use Pterodactyl\Contracts\Repository\SessionRepositoryInterface;
|
use Pterodactyl\Contracts\Repository\SessionRepositoryInterface;
|
||||||
use Pterodactyl\Contracts\Repository\SubuserRepositoryInterface;
|
use Pterodactyl\Contracts\Repository\SubuserRepositoryInterface;
|
||||||
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
|
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
|
||||||
|
@ -36,7 +35,6 @@ use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
|
||||||
use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
|
use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
|
||||||
use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface;
|
use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface;
|
||||||
use Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface;
|
use Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface;
|
||||||
use Pterodactyl\Contracts\Repository\ServerVariableRepositoryInterface;
|
|
||||||
|
|
||||||
class RepositoryServiceProvider extends ServiceProvider
|
class RepositoryServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
@ -57,7 +55,6 @@ class RepositoryServiceProvider extends ServiceProvider
|
||||||
$this->app->bind(NodeRepositoryInterface::class, NodeRepository::class);
|
$this->app->bind(NodeRepositoryInterface::class, NodeRepository::class);
|
||||||
$this->app->bind(ScheduleRepositoryInterface::class, ScheduleRepository::class);
|
$this->app->bind(ScheduleRepositoryInterface::class, ScheduleRepository::class);
|
||||||
$this->app->bind(ServerRepositoryInterface::class, ServerRepository::class);
|
$this->app->bind(ServerRepositoryInterface::class, ServerRepository::class);
|
||||||
$this->app->bind(ServerVariableRepositoryInterface::class, ServerVariableRepository::class);
|
|
||||||
$this->app->bind(SessionRepositoryInterface::class, SessionRepository::class);
|
$this->app->bind(SessionRepositoryInterface::class, SessionRepository::class);
|
||||||
$this->app->bind(SettingsRepositoryInterface::class, SettingsRepository::class);
|
$this->app->bind(SettingsRepositoryInterface::class, SettingsRepository::class);
|
||||||
$this->app->bind(SubuserRepositoryInterface::class, SubuserRepository::class);
|
$this->app->bind(SubuserRepositoryInterface::class, SubuserRepository::class);
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Pterodactyl\Repositories\Eloquent;
|
|
||||||
|
|
||||||
use Pterodactyl\Models\ServerVariable;
|
|
||||||
use Pterodactyl\Contracts\Repository\ServerVariableRepositoryInterface;
|
|
||||||
|
|
||||||
class ServerVariableRepository extends EloquentRepository implements ServerVariableRepositoryInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Return the model backing this repository.
|
|
||||||
*/
|
|
||||||
public function model(): string
|
|
||||||
{
|
|
||||||
return ServerVariable::class;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -10,12 +10,12 @@ use Webmozart\Assert\Assert;
|
||||||
use Pterodactyl\Models\Server;
|
use Pterodactyl\Models\Server;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Pterodactyl\Models\Allocation;
|
use Pterodactyl\Models\Allocation;
|
||||||
|
use Pterodactyl\Models\ServerVariable;
|
||||||
use Illuminate\Database\ConnectionInterface;
|
use Illuminate\Database\ConnectionInterface;
|
||||||
use Pterodactyl\Models\Objects\DeploymentObject;
|
use Pterodactyl\Models\Objects\DeploymentObject;
|
||||||
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
||||||
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
|
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
|
||||||
use Pterodactyl\Services\Deployment\FindViableNodesService;
|
use Pterodactyl\Services\Deployment\FindViableNodesService;
|
||||||
use Pterodactyl\Repositories\Eloquent\ServerVariableRepository;
|
|
||||||
use Pterodactyl\Services\Deployment\AllocationSelectionService;
|
use Pterodactyl\Services\Deployment\AllocationSelectionService;
|
||||||
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
|
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ class ServerCreationService
|
||||||
private FindViableNodesService $findViableNodesService,
|
private FindViableNodesService $findViableNodesService,
|
||||||
private ServerRepository $repository,
|
private ServerRepository $repository,
|
||||||
private ServerDeletionService $serverDeletionService,
|
private ServerDeletionService $serverDeletionService,
|
||||||
private ServerVariableRepository $serverVariableRepository,
|
|
||||||
private VariableValidatorService $validatorService
|
private VariableValidatorService $validatorService
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
@ -196,7 +195,7 @@ class ServerCreationService
|
||||||
})->toArray();
|
})->toArray();
|
||||||
|
|
||||||
if (!empty($records)) {
|
if (!empty($records)) {
|
||||||
$this->serverVariableRepository->insert($records);
|
ServerVariable::query()->insert($records);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue