diff --git a/app/Http/Controllers/Api/Application/ApplicationApiController.php b/app/Http/Controllers/Api/Application/ApplicationApiController.php index 94d9c561..2a696c02 100644 --- a/app/Http/Controllers/Api/Application/ApplicationApiController.php +++ b/app/Http/Controllers/Api/Application/ApplicationApiController.php @@ -44,20 +44,6 @@ abstract class ApplicationApiController extends Controller $this->request = $request; } - /** - * Return an instance of an application transformer. - * - * @return \Pterodactyl\Transformers\Api\Transformer - * - * @throws \Illuminate\Contracts\Container\BindingResolutionException - * - * @deprecated - */ - public function getTransformer(string $abstract) - { - return new $abstract; - } - /** * Return a HTTP/201 response for the API. */ diff --git a/app/Http/Controllers/Api/Application/Databases/DatabaseController.php b/app/Http/Controllers/Api/Application/Databases/DatabaseController.php index a743f6d6..3398572a 100644 --- a/app/Http/Controllers/Api/Application/Databases/DatabaseController.php +++ b/app/Http/Controllers/Api/Application/Databases/DatabaseController.php @@ -51,7 +51,7 @@ class DatabaseController extends ApplicationApiController ->paginate($perPage); return $this->fractal->collection($databases) - ->transformWith($this->getTransformer(DatabaseHostTransformer::class)) + ->transformWith(DatabaseHostTransformer::class) ->toArray(); } @@ -63,7 +63,7 @@ class DatabaseController extends ApplicationApiController public function view(GetDatabaseRequest $request, DatabaseHost $databaseHost): array { return $this->fractal->item($databaseHost) - ->transformWith($this->getTransformer(DatabaseHostTransformer::class)) + ->transformWith(DatabaseHostTransformer::class) ->toArray(); } @@ -77,7 +77,7 @@ class DatabaseController extends ApplicationApiController $databaseHost = $this->creationService->handle($request->validated()); return $this->fractal->item($databaseHost) - ->transformWith($this->getTransformer(DatabaseHostTransformer::class)) + ->transformWith(DatabaseHostTransformer::class) ->respond(JsonResponse::HTTP_CREATED); } @@ -91,7 +91,7 @@ class DatabaseController extends ApplicationApiController $databaseHost = $this->updateService->handle($databaseHost->id, $request->validated()); return $this->fractal->item($databaseHost) - ->transformWith($this->getTransformer(DatabaseHostTransformer::class)) + ->transformWith(DatabaseHostTransformer::class) ->toArray(); } diff --git a/app/Http/Controllers/Api/Application/Eggs/EggController.php b/app/Http/Controllers/Api/Application/Eggs/EggController.php index 25d3a05a..5d5c8572 100644 --- a/app/Http/Controllers/Api/Application/Eggs/EggController.php +++ b/app/Http/Controllers/Api/Application/Eggs/EggController.php @@ -52,7 +52,7 @@ class EggController extends ApplicationApiController } return $this->fractal->collection($eggs) - ->transformWith($this->getTransformer(EggTransformer::class)) + ->transformWith(EggTransformer::class) ->toArray(); } @@ -64,7 +64,7 @@ class EggController extends ApplicationApiController public function view(GetEggRequest $request, Egg $egg): array { return $this->fractal->item($egg) - ->transformWith($this->getTransformer(EggTransformer::class)) + ->transformWith(EggTransformer::class) ->toArray(); } @@ -78,7 +78,7 @@ class EggController extends ApplicationApiController $egg = Egg::query()->create($request->validated()); return $this->fractal->item($egg) - ->transformWith($this->getTransformer(EggTransformer::class)) + ->transformWith(EggTransformer::class) ->respond(JsonResponse::HTTP_CREATED); } @@ -92,7 +92,7 @@ class EggController extends ApplicationApiController $egg->update($request->validated()); return $this->fractal->item($egg) - ->transformWith($this->getTransformer(EggTransformer::class)) + ->transformWith(EggTransformer::class) ->toArray(); } diff --git a/app/Http/Controllers/Api/Application/Locations/LocationController.php b/app/Http/Controllers/Api/Application/Locations/LocationController.php index de121c2e..f737bcc4 100644 --- a/app/Http/Controllers/Api/Application/Locations/LocationController.php +++ b/app/Http/Controllers/Api/Application/Locations/LocationController.php @@ -57,7 +57,7 @@ class LocationController extends ApplicationApiController ->paginate($perPage); return $this->fractal->collection($locations) - ->transformWith($this->getTransformer(LocationTransformer::class)) + ->transformWith(LocationTransformer::class) ->toArray(); } @@ -69,7 +69,7 @@ class LocationController extends ApplicationApiController public function view(GetLocationRequest $request, Location $location): array { return $this->fractal->item($location) - ->transformWith($this->getTransformer(LocationTransformer::class)) + ->transformWith(LocationTransformer::class) ->toArray(); } @@ -85,7 +85,7 @@ class LocationController extends ApplicationApiController $location = $this->creationService->handle($request->validated()); return $this->fractal->item($location) - ->transformWith($this->getTransformer(LocationTransformer::class)) + ->transformWith(LocationTransformer::class) ->addMeta([ 'resource' => route('api.application.locations.view', [ 'location' => $location->id, @@ -106,7 +106,7 @@ class LocationController extends ApplicationApiController $location = $this->updateService->handle($location, $request->validated()); return $this->fractal->item($location) - ->transformWith($this->getTransformer(LocationTransformer::class)) + ->transformWith(LocationTransformer::class) ->toArray(); } diff --git a/app/Http/Controllers/Api/Application/Mounts/MountController.php b/app/Http/Controllers/Api/Application/Mounts/MountController.php index 9070f415..22635354 100644 --- a/app/Http/Controllers/Api/Application/Mounts/MountController.php +++ b/app/Http/Controllers/Api/Application/Mounts/MountController.php @@ -45,7 +45,7 @@ class MountController extends ApplicationApiController ->paginate($perPage); return $this->fractal->collection($mounts) - ->transformWith($this->getTransformer(MountTransformer::class)) + ->transformWith(MountTransformer::class) ->toArray(); } @@ -57,7 +57,7 @@ class MountController extends ApplicationApiController public function view(GetMountRequest $request, Mount $mount): array { return $this->fractal->item($mount) - ->transformWith($this->getTransformer(MountTransformer::class)) + ->transformWith(MountTransformer::class) ->toArray(); } @@ -71,7 +71,7 @@ class MountController extends ApplicationApiController $mount = Mount::query()->create($request->validated()); return $this->fractal->item($mount) - ->transformWith($this->getTransformer(MountTransformer::class)) + ->transformWith(MountTransformer::class) ->respond(JsonResponse::HTTP_CREATED); } @@ -85,7 +85,7 @@ class MountController extends ApplicationApiController $mount->update($request->validated()); return $this->fractal->item($mount) - ->transformWith($this->getTransformer(MountTransformer::class)) + ->transformWith(MountTransformer::class) ->toArray(); } @@ -116,7 +116,7 @@ class MountController extends ApplicationApiController } return $this->fractal->item($mount) - ->transformWith($this->getTransformer(MountTransformer::class)) + ->transformWith(MountTransformer::class) ->toArray(); } @@ -135,7 +135,7 @@ class MountController extends ApplicationApiController } return $this->fractal->item($mount) - ->transformWith($this->getTransformer(MountTransformer::class)) + ->transformWith(MountTransformer::class) ->toArray(); } @@ -154,7 +154,7 @@ class MountController extends ApplicationApiController } return $this->fractal->item($mount) - ->transformWith($this->getTransformer(MountTransformer::class)) + ->transformWith(MountTransformer::class) ->toArray(); } @@ -173,7 +173,7 @@ class MountController extends ApplicationApiController } return $this->fractal->item($mount) - ->transformWith($this->getTransformer(MountTransformer::class)) + ->transformWith(MountTransformer::class) ->toArray(); } } diff --git a/app/Http/Controllers/Api/Application/Nests/NestController.php b/app/Http/Controllers/Api/Application/Nests/NestController.php index 008f4f1d..9872140c 100644 --- a/app/Http/Controllers/Api/Application/Nests/NestController.php +++ b/app/Http/Controllers/Api/Application/Nests/NestController.php @@ -63,7 +63,7 @@ class NestController extends ApplicationApiController } return $this->fractal->collection($nests) - ->transformWith($this->getTransformer(NestTransformer::class)) + ->transformWith(NestTransformer::class) ->toArray(); } @@ -75,7 +75,7 @@ class NestController extends ApplicationApiController public function view(GetNestRequest $request, Nest $nest): array { return $this->fractal->item($nest) - ->transformWith($this->getTransformer(NestTransformer::class)) + ->transformWith(NestTransformer::class) ->toArray(); } @@ -90,7 +90,7 @@ class NestController extends ApplicationApiController $nest = $this->nestCreationService->handle($request->validated()); return $this->fractal->item($nest) - ->transformWith($this->getTransformer(NestTransformer::class)) + ->transformWith(NestTransformer::class) ->toArray(); } @@ -106,7 +106,7 @@ class NestController extends ApplicationApiController $this->nestUpdateService->handle($nest->id, $request->validated()); return $this->fractal->item($nest) - ->transformWith($this->getTransformer(NestTransformer::class)) + ->transformWith(NestTransformer::class) ->toArray(); } diff --git a/app/Http/Controllers/Api/Application/Nodes/AllocationController.php b/app/Http/Controllers/Api/Application/Nodes/AllocationController.php index d993e278..ffa4c2fe 100644 --- a/app/Http/Controllers/Api/Application/Nodes/AllocationController.php +++ b/app/Http/Controllers/Api/Application/Nodes/AllocationController.php @@ -47,7 +47,7 @@ class AllocationController extends ApplicationApiController $allocations = $node->allocations()->paginate($perPage); return $this->fractal->collection($allocations) - ->transformWith($this->getTransformer(AllocationTransformer::class)) + ->transformWith(AllocationTransformer::class) ->toArray(); } diff --git a/app/Http/Controllers/Api/Application/Nodes/NodeController.php b/app/Http/Controllers/Api/Application/Nodes/NodeController.php index fdf86ccc..ef06336f 100644 --- a/app/Http/Controllers/Api/Application/Nodes/NodeController.php +++ b/app/Http/Controllers/Api/Application/Nodes/NodeController.php @@ -61,7 +61,7 @@ class NodeController extends ApplicationApiController ->paginate($perPage); return $this->fractal->collection($nodes) - ->transformWith($this->getTransformer(NodeTransformer::class)) + ->transformWith(NodeTransformer::class) ->toArray(); } @@ -73,7 +73,7 @@ class NodeController extends ApplicationApiController public function view(GetNodeRequest $request, Node $node): array { return $this->fractal->item($node) - ->transformWith($this->getTransformer(NodeTransformer::class)) + ->transformWith(NodeTransformer::class) ->toArray(); } @@ -89,7 +89,7 @@ class NodeController extends ApplicationApiController $node = $this->creationService->handle($request->validated()); return $this->fractal->item($node) - ->transformWith($this->getTransformer(NodeTransformer::class)) + ->transformWith(NodeTransformer::class) ->addMeta([ 'resource' => route('api.application.nodes.view', [ 'node' => $node->id, @@ -112,7 +112,7 @@ class NodeController extends ApplicationApiController ); return $this->fractal->item($node) - ->transformWith($this->getTransformer(NodeTransformer::class)) + ->transformWith(NodeTransformer::class) ->toArray(); } diff --git a/app/Http/Controllers/Api/Application/Nodes/NodeDeploymentController.php b/app/Http/Controllers/Api/Application/Nodes/NodeDeploymentController.php index bb004b5b..cebf5a8a 100644 --- a/app/Http/Controllers/Api/Application/Nodes/NodeDeploymentController.php +++ b/app/Http/Controllers/Api/Application/Nodes/NodeDeploymentController.php @@ -38,7 +38,7 @@ class NodeDeploymentController extends ApplicationApiController ->handle($request->query('per_page'), $request->query('page')); return $this->fractal->collection($nodes) - ->transformWith($this->getTransformer(NodeTransformer::class)) + ->transformWith(NodeTransformer::class) ->toArray(); } } diff --git a/app/Http/Controllers/Api/Application/Roles/RoleController.php b/app/Http/Controllers/Api/Application/Roles/RoleController.php index e4cff282..904d389e 100644 --- a/app/Http/Controllers/Api/Application/Roles/RoleController.php +++ b/app/Http/Controllers/Api/Application/Roles/RoleController.php @@ -43,7 +43,7 @@ class RoleController extends ApplicationApiController ->paginate($perPage); return $this->fractal->collection($roles) - ->transformWith($this->getTransformer(AdminRoleTransformer::class)) + ->transformWith(AdminRoleTransformer::class) ->toArray(); } @@ -55,7 +55,7 @@ class RoleController extends ApplicationApiController public function view(GetRoleRequest $request, AdminRole $role): array { return $this->fractal->item($role) - ->transformWith($this->getTransformer(AdminRoleTransformer::class)) + ->transformWith(AdminRoleTransformer::class) ->toArray(); } @@ -72,7 +72,7 @@ class RoleController extends ApplicationApiController $role = AdminRole::query()->create($data); return $this->fractal->item($role) - ->transformWith($this->getTransformer(AdminRoleTransformer::class)) + ->transformWith(AdminRoleTransformer::class) ->respond(JsonResponse::HTTP_CREATED); } @@ -86,7 +86,7 @@ class RoleController extends ApplicationApiController $role->update($request->validated()); return $this->fractal->item($role) - ->transformWith($this->getTransformer(AdminRoleTransformer::class)) + ->transformWith(AdminRoleTransformer::class) ->toArray(); } diff --git a/app/Http/Controllers/Api/Application/Servers/DatabaseController.php b/app/Http/Controllers/Api/Application/Servers/DatabaseController.php index 3f3b3efb..5089e1e0 100644 --- a/app/Http/Controllers/Api/Application/Servers/DatabaseController.php +++ b/app/Http/Controllers/Api/Application/Servers/DatabaseController.php @@ -46,7 +46,7 @@ class DatabaseController extends ApplicationApiController public function index(GetServerDatabasesRequest $request, Server $server): array { return $this->fractal->collection($server->databases) - ->transformWith($this->getTransformer(ServerDatabaseTransformer::class)) + ->transformWith(ServerDatabaseTransformer::class) ->toArray(); } @@ -58,7 +58,7 @@ class DatabaseController extends ApplicationApiController public function view(GetServerDatabaseRequest $request, Server $server, Database $database): array { return $this->fractal->item($database) - ->transformWith($this->getTransformer(ServerDatabaseTransformer::class)) + ->transformWith(ServerDatabaseTransformer::class) ->toArray(); } @@ -86,7 +86,7 @@ class DatabaseController extends ApplicationApiController ])); return $this->fractal->item($database) - ->transformWith($this->getTransformer(ServerDatabaseTransformer::class)) + ->transformWith(ServerDatabaseTransformer::class) ->addMeta([ 'resource' => route('api.application.servers.databases.view', [ 'server' => $server->id, diff --git a/app/Http/Controllers/Api/Application/Servers/ExternalServerController.php b/app/Http/Controllers/Api/Application/Servers/ExternalServerController.php index fd8c37a1..8e35e027 100644 --- a/app/Http/Controllers/Api/Application/Servers/ExternalServerController.php +++ b/app/Http/Controllers/Api/Application/Servers/ExternalServerController.php @@ -19,7 +19,7 @@ class ExternalServerController extends ApplicationApiController $server = Server::query()->where('external_id', $external_id)->firstOrFail(); return $this->fractal->item($server) - ->transformWith($this->getTransformer(ServerTransformer::class)) + ->transformWith(ServerTransformer::class) ->toArray(); } } diff --git a/app/Http/Controllers/Api/Application/Servers/ServerController.php b/app/Http/Controllers/Api/Application/Servers/ServerController.php index da537c9e..9d650c02 100644 --- a/app/Http/Controllers/Api/Application/Servers/ServerController.php +++ b/app/Http/Controllers/Api/Application/Servers/ServerController.php @@ -52,7 +52,7 @@ class ServerController extends ApplicationApiController ->paginate($perPage); return $this->fractal->collection($servers) - ->transformWith($this->getTransformer(ServerTransformer::class)) + ->transformWith(ServerTransformer::class) ->toArray(); } @@ -71,7 +71,7 @@ class ServerController extends ApplicationApiController $server = $this->creationService->handle($request->validated(), $request->getDeploymentObject()); return $this->fractal->item($server) - ->transformWith($this->getTransformer(ServerTransformer::class)) + ->transformWith(ServerTransformer::class) ->respond(Response::HTTP_CREATED); } @@ -83,7 +83,7 @@ class ServerController extends ApplicationApiController public function view(GetServerRequest $request, Server $server): array { return $this->fractal->item($server) - ->transformWith($this->getTransformer(ServerTransformer::class)) + ->transformWith(ServerTransformer::class) ->toArray(); } diff --git a/app/Http/Controllers/Api/Application/Servers/ServerDetailsController.php b/app/Http/Controllers/Api/Application/Servers/ServerDetailsController.php index 857d46f2..f4d403db 100644 --- a/app/Http/Controllers/Api/Application/Servers/ServerDetailsController.php +++ b/app/Http/Controllers/Api/Application/Servers/ServerDetailsController.php @@ -41,7 +41,7 @@ class ServerDetailsController extends ApplicationApiController ); return $this->fractal->item($server) - ->transformWith($this->getTransformer(ServerTransformer::class)) + ->transformWith(ServerTransformer::class) ->toArray(); } @@ -55,7 +55,7 @@ class ServerDetailsController extends ApplicationApiController $server = $this->buildModificationService->handle($server, $request->validated()); return $this->fractal->item($server) - ->transformWith($this->getTransformer(ServerTransformer::class)) + ->transformWith(ServerTransformer::class) ->toArray(); } } diff --git a/app/Http/Controllers/Api/Application/Servers/StartupController.php b/app/Http/Controllers/Api/Application/Servers/StartupController.php index 1513be2f..123dcdeb 100644 --- a/app/Http/Controllers/Api/Application/Servers/StartupController.php +++ b/app/Http/Controllers/Api/Application/Servers/StartupController.php @@ -35,7 +35,7 @@ class StartupController extends ApplicationApiController ->handle($server, $request->validated()); return $this->fractal->item($server) - ->transformWith($this->getTransformer(ServerTransformer::class)) + ->transformWith(ServerTransformer::class) ->toArray(); } } diff --git a/app/Http/Controllers/Api/Application/Users/ExternalUserController.php b/app/Http/Controllers/Api/Application/Users/ExternalUserController.php index b7d653c3..9129578f 100644 --- a/app/Http/Controllers/Api/Application/Users/ExternalUserController.php +++ b/app/Http/Controllers/Api/Application/Users/ExternalUserController.php @@ -19,7 +19,7 @@ class ExternalUserController extends ApplicationApiController $user = User::query()->where('external_id', $external_id)->firstOrFail(); return $this->fractal->item($user) - ->transformWith($this->getTransformer(UserTransformer::class)) + ->transformWith(UserTransformer::class) ->toArray(); } } diff --git a/app/Http/Controllers/Api/Application/Users/UserController.php b/app/Http/Controllers/Api/Application/Users/UserController.php index 5fe2ca75..59219218 100644 --- a/app/Http/Controllers/Api/Application/Users/UserController.php +++ b/app/Http/Controllers/Api/Application/Users/UserController.php @@ -63,7 +63,7 @@ class UserController extends ApplicationApiController ->paginate($perPage); return $this->fractal->collection($users) - ->transformWith($this->getTransformer(UserTransformer::class)) + ->transformWith(UserTransformer::class) ->toArray(); } @@ -76,7 +76,7 @@ class UserController extends ApplicationApiController public function view(GetUserRequest $request, User $user): array { return $this->fractal->item($user) - ->transformWith($this->getTransformer(UserTransformer::class)) + ->transformWith(UserTransformer::class) ->toArray(); } @@ -98,7 +98,7 @@ class UserController extends ApplicationApiController $user = $this->updateService->handle($user, $request->validated()); return $this->fractal->item($user) - ->transformWith($this->getTransformer(UserTransformer::class)) + ->transformWith(UserTransformer::class) ->toArray(); } @@ -114,7 +114,7 @@ class UserController extends ApplicationApiController $user = $this->creationService->handle($request->validated()); return $this->fractal->item($user) - ->transformWith($this->getTransformer(UserTransformer::class)) + ->transformWith(UserTransformer::class) ->addMeta([ 'resource' => route('api.application.users.view', [ 'user' => $user->id, diff --git a/app/Http/Controllers/Api/Client/ApiKeyController.php b/app/Http/Controllers/Api/Client/ApiKeyController.php index 8f09a616..a7331e67 100644 --- a/app/Http/Controllers/Api/Client/ApiKeyController.php +++ b/app/Http/Controllers/Api/Client/ApiKeyController.php @@ -19,7 +19,7 @@ class ApiKeyController extends ClientApiController public function index(AccountApiRequest $request): array { return $this->fractal->collection($request->user()->tokens) - ->transformWith($this->getTransformer(PersonalAccessTokenTransformer::class)) + ->transformWith(PersonalAccessTokenTransformer::class) ->toArray(); } @@ -40,7 +40,7 @@ class ApiKeyController extends ClientApiController [$token, $plaintext] = $request->user()->createToken($request->input('description')); return $this->fractal->item($token) - ->transformWith($this->getTransformer(PersonalAccessTokenTransformer::class)) + ->transformWith(PersonalAccessTokenTransformer::class) ->addMeta([ 'secret_token' => $plaintext, ]) diff --git a/app/Http/Controllers/Api/Client/ClientApiController.php b/app/Http/Controllers/Api/Client/ClientApiController.php index c1dac9bb..05dbb889 100644 --- a/app/Http/Controllers/Api/Client/ClientApiController.php +++ b/app/Http/Controllers/Api/Client/ClientApiController.php @@ -2,7 +2,6 @@ namespace Pterodactyl\Http\Controllers\Api\Client; -use Webmozart\Assert\Assert; use Pterodactyl\Transformers\Api\Transformer; use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController; @@ -39,20 +38,4 @@ abstract class ClientApiController extends ApplicationApiController return trim($item); }, explode(',', $includes)); } - - /** - * Return an instance of an application transformer. - * - * @return \Pterodactyl\Transformers\Api\Transformer - * - * @deprecated - */ - public function getTransformer(string $class) - { - $transformer = new $class; - - Assert::same(substr($class, 0, strlen(class_basename($class)) * -1), '\Pterodactyl\Transformers\Api\Client\\'); - - return $transformer; - } } diff --git a/app/Http/Controllers/Api/Client/ClientController.php b/app/Http/Controllers/Api/Client/ClientController.php index 804a1d21..53e84603 100644 --- a/app/Http/Controllers/Api/Client/ClientController.php +++ b/app/Http/Controllers/Api/Client/ClientController.php @@ -34,7 +34,7 @@ class ClientController extends ClientApiController public function index(GetServersRequest $request): array { $user = $request->user(); - $transformer = $this->getTransformer(ServerTransformer::class); + $transformer = ServerTransformer::class; // Start the query builder and ensure we eager load any requested relationships from the request. $builder = QueryBuilder::for( diff --git a/app/Http/Controllers/Api/Client/SSHKeyController.php b/app/Http/Controllers/Api/Client/SSHKeyController.php index 848712f9..dc87b4cf 100644 --- a/app/Http/Controllers/Api/Client/SSHKeyController.php +++ b/app/Http/Controllers/Api/Client/SSHKeyController.php @@ -20,7 +20,7 @@ class SSHKeyController extends ClientApiController public function index(Request $request): \Pterodactyl\Extensions\Spatie\Fractalistic\Fractal { return $this->fractal->collection(UserSSHKey::query()->where('user_id', '=', $request->user()->id)->get()) - ->transformWith($this->getTransformer(UserSSHKeyTransformer::class)); + ->transformWith(UserSSHKeyTransformer::class); } /** @@ -42,7 +42,7 @@ class SSHKeyController extends ClientApiController $key = UserSSHKey::query()->create($data); return $this->fractal->item($key) - ->transformWith($this->getTransformer(UserSSHKeyTransformer::class)) + ->transformWith(UserSSHKeyTransformer::class) ->respond(JsonResponse::HTTP_CREATED); } diff --git a/app/Http/Controllers/Api/Client/Servers/BackupController.php b/app/Http/Controllers/Api/Client/Servers/BackupController.php index a12772f0..f2dd8d40 100644 --- a/app/Http/Controllers/Api/Client/Servers/BackupController.php +++ b/app/Http/Controllers/Api/Client/Servers/BackupController.php @@ -63,7 +63,7 @@ class BackupController extends ClientApiController $limit = min($request->query('per_page') ?? 20, 50); return $this->fractal->collection($server->backups()->paginate($limit)) - ->transformWith($this->getTransformer(BackupTransformer::class)) + ->transformWith(BackupTransformer::class) ->addMeta([ 'backup_count' => $this->repository->getNonFailedBackups($server)->count(), ]) @@ -100,7 +100,7 @@ class BackupController extends ClientApiController }); return $this->fractal->item($backup) - ->transformWith($this->getTransformer(BackupTransformer::class)) + ->transformWith(BackupTransformer::class) ->toArray(); } @@ -126,7 +126,7 @@ class BackupController extends ClientApiController $backup->refresh(); return $this->fractal->item($backup) - ->transformWith($this->getTransformer(BackupTransformer::class)) + ->transformWith(BackupTransformer::class) ->toArray(); } @@ -142,7 +142,7 @@ class BackupController extends ClientApiController } return $this->fractal->item($backup) - ->transformWith($this->getTransformer(BackupTransformer::class)) + ->transformWith(BackupTransformer::class) ->toArray(); } diff --git a/app/Http/Controllers/Api/Client/Servers/DatabaseController.php b/app/Http/Controllers/Api/Client/Servers/DatabaseController.php index c3a5cb0d..2b5258fb 100644 --- a/app/Http/Controllers/Api/Client/Servers/DatabaseController.php +++ b/app/Http/Controllers/Api/Client/Servers/DatabaseController.php @@ -48,7 +48,7 @@ class DatabaseController extends ClientApiController public function index(GetDatabasesRequest $request, Server $server): array { return $this->fractal->collection($server->databases) - ->transformWith($this->getTransformer(DatabaseTransformer::class)) + ->transformWith(DatabaseTransformer::class) ->toArray(); } @@ -65,7 +65,7 @@ class DatabaseController extends ClientApiController return $this->fractal->item($database) ->parseIncludes(['password']) - ->transformWith($this->getTransformer(DatabaseTransformer::class)) + ->transformWith(DatabaseTransformer::class) ->toArray(); } @@ -82,7 +82,7 @@ class DatabaseController extends ClientApiController return $this->fractal->item($database) ->parseIncludes(['password']) - ->transformWith($this->getTransformer(DatabaseTransformer::class)) + ->transformWith(DatabaseTransformer::class) ->toArray(); } diff --git a/app/Http/Controllers/Api/Client/Servers/FileController.php b/app/Http/Controllers/Api/Client/Servers/FileController.php index a425a82f..caf8e7ee 100644 --- a/app/Http/Controllers/Api/Client/Servers/FileController.php +++ b/app/Http/Controllers/Api/Client/Servers/FileController.php @@ -57,7 +57,7 @@ class FileController extends ClientApiController ->getDirectory($request->get('directory') ?? '/'); return $this->fractal->collection($contents) - ->transformWith($this->getTransformer(FileObjectTransformer::class)) + ->transformWith(FileObjectTransformer::class) ->toArray(); } @@ -202,7 +202,7 @@ class FileController extends ClientApiController }); return $this->fractal->item($file) - ->transformWith($this->getTransformer(FileObjectTransformer::class)) + ->transformWith(FileObjectTransformer::class) ->toArray(); } diff --git a/app/Http/Controllers/Api/Client/Servers/NetworkAllocationController.php b/app/Http/Controllers/Api/Client/Servers/NetworkAllocationController.php index aabbe15d..606cabef 100644 --- a/app/Http/Controllers/Api/Client/Servers/NetworkAllocationController.php +++ b/app/Http/Controllers/Api/Client/Servers/NetworkAllocationController.php @@ -47,7 +47,7 @@ class NetworkAllocationController extends ClientApiController public function index(GetNetworkRequest $request, Server $server): array { return $this->fractal->collection($server->allocations) - ->transformWith($this->getTransformer(AllocationTransformer::class)) + ->transformWith(AllocationTransformer::class) ->toArray(); } @@ -65,7 +65,7 @@ class NetworkAllocationController extends ClientApiController ]); return $this->fractal->item($allocation) - ->transformWith($this->getTransformer(AllocationTransformer::class)) + ->transformWith(AllocationTransformer::class) ->toArray(); } @@ -81,7 +81,7 @@ class NetworkAllocationController extends ClientApiController $this->serverRepository->update($server->id, ['allocation_id' => $allocation->id]); return $this->fractal->item($allocation) - ->transformWith($this->getTransformer(AllocationTransformer::class)) + ->transformWith(AllocationTransformer::class) ->toArray(); } @@ -100,7 +100,7 @@ class NetworkAllocationController extends ClientApiController $allocation = $this->assignableAllocationService->handle($server); return $this->fractal->item($allocation) - ->transformWith($this->getTransformer(AllocationTransformer::class)) + ->transformWith(AllocationTransformer::class) ->toArray(); } diff --git a/app/Http/Controllers/Api/Client/Servers/ResourceUtilizationController.php b/app/Http/Controllers/Api/Client/Servers/ResourceUtilizationController.php index 5031690e..5bf8317e 100644 --- a/app/Http/Controllers/Api/Client/Servers/ResourceUtilizationController.php +++ b/app/Http/Controllers/Api/Client/Servers/ResourceUtilizationController.php @@ -42,7 +42,7 @@ class ResourceUtilizationController extends ClientApiController }); return $this->fractal->item($stats) - ->transformWith($this->getTransformer(StatsTransformer::class)) + ->transformWith(StatsTransformer::class) ->toArray(); } } diff --git a/app/Http/Controllers/Api/Client/Servers/ScheduleController.php b/app/Http/Controllers/Api/Client/Servers/ScheduleController.php index be41317c..28f3c791 100644 --- a/app/Http/Controllers/Api/Client/Servers/ScheduleController.php +++ b/app/Http/Controllers/Api/Client/Servers/ScheduleController.php @@ -49,7 +49,7 @@ class ScheduleController extends ClientApiController $schedules->loadMissing('tasks'); return $this->fractal->collection($schedules) - ->transformWith($this->getTransformer(ScheduleTransformer::class)) + ->transformWith(ScheduleTransformer::class) ->toArray(); } @@ -77,7 +77,7 @@ class ScheduleController extends ClientApiController ]); return $this->fractal->item($model) - ->transformWith($this->getTransformer(ScheduleTransformer::class)) + ->transformWith(ScheduleTransformer::class) ->toArray(); } @@ -91,7 +91,7 @@ class ScheduleController extends ClientApiController $schedule->loadMissing('tasks'); return $this->fractal->item($schedule) - ->transformWith($this->getTransformer(ScheduleTransformer::class)) + ->transformWith(ScheduleTransformer::class) ->toArray(); } @@ -130,7 +130,7 @@ class ScheduleController extends ClientApiController $this->repository->update($schedule->id, $data); return $this->fractal->item($schedule->refresh()) - ->transformWith($this->getTransformer(ScheduleTransformer::class)) + ->transformWith(ScheduleTransformer::class) ->toArray(); } diff --git a/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php b/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php index 4ae72642..d025f271 100644 --- a/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php +++ b/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php @@ -64,7 +64,7 @@ class ScheduleTaskController extends ClientApiController ]); return $this->fractal->item($task) - ->transformWith($this->getTransformer(TaskTransformer::class)) + ->transformWith(TaskTransformer::class) ->toArray(); } @@ -94,7 +94,7 @@ class ScheduleTaskController extends ClientApiController ]); return $this->fractal->item($task->refresh()) - ->transformWith($this->getTransformer(TaskTransformer::class)) + ->transformWith(TaskTransformer::class) ->toArray(); } diff --git a/app/Http/Controllers/Api/Client/Servers/ServerController.php b/app/Http/Controllers/Api/Client/Servers/ServerController.php index 1702ee71..7c1e17e0 100644 --- a/app/Http/Controllers/Api/Client/Servers/ServerController.php +++ b/app/Http/Controllers/Api/Client/Servers/ServerController.php @@ -34,7 +34,7 @@ class ServerController extends ClientApiController public function index(GetServerRequest $request, Server $server): array { return $this->fractal->item($server) - ->transformWith($this->getTransformer(ServerTransformer::class)) + ->transformWith(ServerTransformer::class) ->addMeta([ 'is_server_owner' => $request->user()->id === $server->owner_id, 'user_permissions' => $this->permissionsService->handle($server, $request->user()), diff --git a/app/Http/Controllers/Api/Client/Servers/StartupController.php b/app/Http/Controllers/Api/Client/Servers/StartupController.php index 6f9c634b..856bae29 100644 --- a/app/Http/Controllers/Api/Client/Servers/StartupController.php +++ b/app/Http/Controllers/Api/Client/Servers/StartupController.php @@ -42,7 +42,7 @@ class StartupController extends ClientApiController return $this->fractal->collection( $server->variables()->where('user_viewable', true)->get() ) - ->transformWith($this->getTransformer(EggVariableTransformer::class)) + ->transformWith(EggVariableTransformer::class) ->addMeta([ 'startup_command' => $startup, 'docker_images' => $server->egg->docker_images, @@ -86,7 +86,7 @@ class StartupController extends ClientApiController $startup = $this->startupCommandService->handle($server, false); return $this->fractal->item($variable) - ->transformWith($this->getTransformer(EggVariableTransformer::class)) + ->transformWith(EggVariableTransformer::class) ->addMeta([ 'startup_command' => $startup, 'raw_startup_command' => $server->startup, diff --git a/app/Http/Controllers/Api/Client/Servers/SubuserController.php b/app/Http/Controllers/Api/Client/Servers/SubuserController.php index d85468f0..807a1098 100644 --- a/app/Http/Controllers/Api/Client/Servers/SubuserController.php +++ b/app/Http/Controllers/Api/Client/Servers/SubuserController.php @@ -48,7 +48,7 @@ class SubuserController extends ClientApiController public function index(GetSubuserRequest $request, Server $server): array { return $this->fractal->collection($server->subusers) - ->transformWith($this->getTransformer(SubuserTransformer::class)) + ->transformWith(SubuserTransformer::class) ->toArray(); } @@ -60,7 +60,7 @@ class SubuserController extends ClientApiController public function view(GetSubuserRequest $request, Server $server, Subuser $subuser): array { return $this->fractal->item($subuser) - ->transformWith($this->getTransformer(SubuserTransformer::class)) + ->transformWith(SubuserTransformer::class) ->toArray(); } @@ -81,7 +81,7 @@ class SubuserController extends ClientApiController ); return $this->fractal->item($response) - ->transformWith($this->getTransformer(SubuserTransformer::class)) + ->transformWith(SubuserTransformer::class) ->toArray(); } @@ -117,7 +117,7 @@ class SubuserController extends ClientApiController } return $this->fractal->item($subuser->refresh()) - ->transformWith($this->getTransformer(SubuserTransformer::class)) + ->transformWith(SubuserTransformer::class) ->toArray(); } diff --git a/app/Http/Controllers/Api/Client/WebauthnController.php b/app/Http/Controllers/Api/Client/WebauthnController.php index c88d8eba..6d042fa4 100644 --- a/app/Http/Controllers/Api/Client/WebauthnController.php +++ b/app/Http/Controllers/Api/Client/WebauthnController.php @@ -24,7 +24,7 @@ class WebauthnController extends ClientApiController public function index(Request $request): array { return $this->fractal->collection(WebauthnKey::query()->where('user_id', '=', $request->user()->id)->get()) - ->transformWith($this->getTransformer(WebauthnKeyTransformer::class)) + ->transformWith(WebauthnKeyTransformer::class) ->toArray(); } @@ -88,7 +88,7 @@ class WebauthnController extends ClientApiController ); return $this->fractal->item($webauthnKey) - ->transformWith($this->getTransformer(WebauthnKeyTransformer::class)) + ->transformWith(WebauthnKeyTransformer::class) ->toArray(); } catch (Exception $e) { return new JsonResponse([ diff --git a/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php b/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php index e5a99512..0be67176 100644 --- a/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php +++ b/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php @@ -5,7 +5,6 @@ namespace Pterodactyl\Tests\Integration\Api\Application; use Pterodactyl\Models\User; use Pterodactyl\Models\ApiKey; use Pterodactyl\Services\Acl\Api\AdminAcl; -use Pterodactyl\Transformers\Api\Transformer; use Pterodactyl\Tests\Integration\IntegrationTestCase; use Illuminate\Foundation\Testing\DatabaseTransactions; use Pterodactyl\Tests\Traits\Integration\CreatesTestModels; @@ -122,16 +121,4 @@ abstract class ApplicationApiIntegrationTestCase extends IntegrationTestCase 'r_server_databases' => AdminAcl::READ | AdminAcl::WRITE, ], $permissions)); } - - /** - * Return a transformer that can be used for testing purposes. - * - * @param string $abstract - * - * @return \Pterodactyl\Transformers\Api\Transformer - */ - protected function getTransformer(string $abstract): Transformer - { - return new $abstract; - } } diff --git a/tests/Integration/Api/Application/Eggs/EggControllerTest.php b/tests/Integration/Api/Application/Eggs/EggControllerTest.php index 3beb536f..96bdda77 100644 --- a/tests/Integration/Api/Application/Eggs/EggControllerTest.php +++ b/tests/Integration/Api/Application/Eggs/EggControllerTest.php @@ -56,7 +56,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase $egg = $eggs->where('id', '=', $datum['attributes']['id'])->first(); $expected = json_encode(Arr::sortRecursive($datum['attributes'])); - $actual = json_encode(Arr::sortRecursive($this->getTransformer(EggTransformer::class)->transform($egg))); + $actual = json_encode(Arr::sortRecursive((new EggTransformer())->transform($egg))); $this->assertSame( $expected, @@ -84,7 +84,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase $response->assertJson([ 'object' => 'egg', - 'attributes' => $this->getTransformer(EggTransformer::class)->transform($egg), + 'attributes' => (new EggTransformer())->transform($egg), ], true); } diff --git a/tests/Integration/Api/Application/Location/LocationControllerTest.php b/tests/Integration/Api/Application/Location/LocationControllerTest.php index 44aee54a..463effd4 100644 --- a/tests/Integration/Api/Application/Location/LocationControllerTest.php +++ b/tests/Integration/Api/Application/Location/LocationControllerTest.php @@ -118,7 +118,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase 'data' => [ [ 'object' => 'node', - 'attributes' => $this->getTransformer(NodeTransformer::class)->transform($server->getRelation('node')), + 'attributes' => (new NodeTransformer())->transform($server->getRelation('node')), ], ], ], @@ -127,7 +127,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase 'data' => [ [ 'object' => 'server', - 'attributes' => $this->getTransformer(ServerTransformer::class)->transform($server), + 'attributes' => (new ServerTransformer())->transform($server), ], ], ], diff --git a/tests/Integration/Api/Application/Nests/NestControllerTest.php b/tests/Integration/Api/Application/Nests/NestControllerTest.php index 7aba83c2..935b9156 100644 --- a/tests/Integration/Api/Application/Nests/NestControllerTest.php +++ b/tests/Integration/Api/Application/Nests/NestControllerTest.php @@ -59,7 +59,7 @@ class NestControllerTest extends ApplicationApiIntegrationTestCase foreach ($nests as $nest) { $response->assertJsonFragment([ 'object' => 'nest', - 'attributes' => $this->getTransformer(NestTransformer::class)->transform($nest), + 'attributes' => (new NestTransformer())->transform($nest), ]); } } @@ -80,7 +80,7 @@ class NestControllerTest extends ApplicationApiIntegrationTestCase $response->assertJson([ 'object' => 'nest', - 'attributes' => $this->getTransformer(NestTransformer::class)->transform($nest), + 'attributes' => (new NestTransformer())->transform($nest), ]); } diff --git a/tests/Integration/Api/Application/Users/UserControllerTest.php b/tests/Integration/Api/Application/Users/UserControllerTest.php index cf88deed..ce32c6be 100644 --- a/tests/Integration/Api/Application/Users/UserControllerTest.php +++ b/tests/Integration/Api/Application/Users/UserControllerTest.php @@ -140,7 +140,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase 'data' => [ [ 'object' => 'server', - 'attributes' => $this->getTransformer(ServerTransformer::class)->transform($server), + 'attributes' => (new ServerTransformer())->transform($server), ], ], ]); @@ -238,7 +238,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase $user = User::where('username', 'testuser')->first(); $response->assertJson([ 'object' => 'user', - 'attributes' => $this->getTransformer(UserTransformer::class)->transform($user), + 'attributes' => (new UserTransformer())->transform($user), 'meta' => [ 'resource' => route('api.application.users.view', $user->id), ], @@ -268,7 +268,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase $response->assertJson([ 'object' => 'user', - 'attributes' => $this->getTransformer(UserTransformer::class)->transform($user), + 'attributes' => (new UserTransformer())->transform($user), ]); }