Upgrade to Laravel 9 (#4413)

Co-authored-by: DaneEveritt <dane@daneeveritt.com>
This commit is contained in:
Matthew Penner 2022-10-14 10:59:20 -06:00 committed by GitHub
parent 95e15d2c8a
commit cbcf62086f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
573 changed files with 4387 additions and 9411 deletions

View file

@ -13,15 +13,9 @@ use Pterodactyl\Transformers\Api\Application\BaseTransformer;
abstract class ApplicationApiController extends Controller
{
/**
* @var \Illuminate\Http\Request
*/
protected $request;
protected Request $request;
/**
* @var \Pterodactyl\Extensions\Spatie\Fractalistic\Fractal
*/
protected $fractal;
protected Fractal $fractal;
/**
* ApplicationApiController constructor.
@ -30,7 +24,7 @@ abstract class ApplicationApiController extends Controller
{
Container::getInstance()->call([$this, 'loadDependencies']);
// Parse all of the includes to use on this request.
// Parse all the includes to use on this request.
$input = $this->request->input('include', []);
$input = is_array($input) ? $input : explode(',', $input);
@ -62,7 +56,6 @@ abstract class ApplicationApiController extends Controller
* @return T
*
* @noinspection PhpDocSignatureInspection
* @noinspection PhpUndefinedClassInspection
*/
public function getTransformer(string $abstract)
{
@ -72,7 +65,7 @@ abstract class ApplicationApiController extends Controller
}
/**
* Return a HTTP/204 response for the API.
* Return an HTTP/204 response for the API.
*/
protected function returnNoContent(): Response
{

View file

@ -9,7 +9,6 @@ use Spatie\QueryBuilder\QueryBuilder;
use Pterodactyl\Services\Locations\LocationUpdateService;
use Pterodactyl\Services\Locations\LocationCreationService;
use Pterodactyl\Services\Locations\LocationDeletionService;
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
use Pterodactyl\Transformers\Api\Application\LocationTransformer;
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
use Pterodactyl\Http\Requests\Api\Application\Locations\GetLocationRequest;
@ -20,45 +19,19 @@ use Pterodactyl\Http\Requests\Api\Application\Locations\UpdateLocationRequest;
class LocationController extends ApplicationApiController
{
/**
* @var \Pterodactyl\Services\Locations\LocationCreationService
*/
private $creationService;
/**
* @var \Pterodactyl\Services\Locations\LocationDeletionService
*/
private $deletionService;
/**
* @var \Pterodactyl\Contracts\Repository\LocationRepositoryInterface
*/
private $repository;
/**
* @var \Pterodactyl\Services\Locations\LocationUpdateService
*/
private $updateService;
/**
* LocationController constructor.
*/
public function __construct(
LocationCreationService $creationService,
LocationDeletionService $deletionService,
LocationRepositoryInterface $repository,
LocationUpdateService $updateService
private LocationCreationService $creationService,
private LocationDeletionService $deletionService,
private LocationUpdateService $updateService
) {
parent::__construct();
$this->creationService = $creationService;
$this->deletionService = $deletionService;
$this->repository = $repository;
$this->updateService = $updateService;
}
/**
* Return all of the locations currently registered on the Panel.
* Return all the locations currently registered on the Panel.
*/
public function index(GetLocationsRequest $request): array
{
@ -83,7 +56,7 @@ class LocationController extends ApplicationApiController
}
/**
* Store a new location on the Panel and return a HTTP/201 response code with the
* Store a new location on the Panel and return an HTTP/201 response code with the
* new location attached.
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException

View file

@ -10,19 +10,12 @@ use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
class NestController extends ApplicationApiController
{
/**
* @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface
*/
private $repository;
/**
* NestController constructor.
*/
public function __construct(NestRepositoryInterface $repository)
public function __construct(private NestRepositoryInterface $repository)
{
parent::__construct();
$this->repository = $repository;
}
/**

View file

@ -18,31 +18,18 @@ use Pterodactyl\Http\Requests\Api\Application\Allocations\DeleteAllocationReques
class AllocationController extends ApplicationApiController
{
/**
* @var \Pterodactyl\Services\Allocations\AssignmentService
*/
private $assignmentService;
/**
* @var \Pterodactyl\Services\Allocations\AllocationDeletionService
*/
private $deletionService;
/**
* AllocationController constructor.
*/
public function __construct(
AssignmentService $assignmentService,
AllocationDeletionService $deletionService
private AssignmentService $assignmentService,
private AllocationDeletionService $deletionService
) {
parent::__construct();
$this->assignmentService = $assignmentService;
$this->deletionService = $deletionService;
}
/**
* Return all of the allocations that exist for a given node.
* Return all the allocations that exist for a given node.
*/
public function index(GetAllocationsRequest $request, Node $node): array
{

View file

@ -13,10 +13,8 @@ class NodeConfigurationController extends ApplicationApiController
* Returns the configuration information for a node. This allows for automated deployments
* to remote machines so long as an API key is provided to the machine to make the request
* with, and the node is known.
*
* @return \Illuminate\Http\JsonResponse
*/
public function __invoke(GetNodeRequest $request, Node $node)
public function __invoke(GetNodeRequest $request, Node $node): JsonResponse
{
return new JsonResponse($node->getConfiguration());
}

View file

@ -8,7 +8,6 @@ use Spatie\QueryBuilder\QueryBuilder;
use Pterodactyl\Services\Nodes\NodeUpdateService;
use Pterodactyl\Services\Nodes\NodeCreationService;
use Pterodactyl\Services\Nodes\NodeDeletionService;
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
use Pterodactyl\Transformers\Api\Application\NodeTransformer;
use Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodeRequest;
use Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodesRequest;
@ -19,45 +18,19 @@ use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
class NodeController extends ApplicationApiController
{
/**
* @var \Pterodactyl\Services\Nodes\NodeCreationService
*/
private $creationService;
/**
* @var \Pterodactyl\Services\Nodes\NodeDeletionService
*/
private $deletionService;
/**
* @var \Pterodactyl\Contracts\Repository\NodeRepositoryInterface
*/
private $repository;
/**
* @var \Pterodactyl\Services\Nodes\NodeUpdateService
*/
private $updateService;
/**
* NodeController constructor.
*/
public function __construct(
NodeCreationService $creationService,
NodeDeletionService $deletionService,
NodeUpdateService $updateService,
NodeRepositoryInterface $repository
private NodeCreationService $creationService,
private NodeDeletionService $deletionService,
private NodeUpdateService $updateService
) {
parent::__construct();
$this->repository = $repository;
$this->creationService = $creationService;
$this->deletionService = $deletionService;
$this->updateService = $updateService;
}
/**
* Return all of the nodes currently available on the Panel.
* Return all the nodes currently available on the Panel.
*/
public function index(GetNodesRequest $request): array
{
@ -82,7 +55,7 @@ class NodeController extends ApplicationApiController
}
/**
* Create a new node on the Panel. Returns the created node and a HTTP/201
* Create a new node on the Panel. Returns the created node and an HTTP/201
* status response on success.
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException

View file

@ -9,19 +9,12 @@ use Pterodactyl\Http\Requests\Api\Application\Nodes\GetDeployableNodesRequest;
class NodeDeploymentController extends ApplicationApiController
{
/**
* @var \Pterodactyl\Services\Deployment\FindViableNodesService
*/
private $viableNodesService;
/**
* NodeDeploymentController constructor.
*/
public function __construct(FindViableNodesService $viableNodesService)
public function __construct(private FindViableNodesService $viableNodesService)
{
parent::__construct();
$this->viableNodesService = $viableNodesService;
}
/**

View file

@ -8,7 +8,6 @@ use Pterodactyl\Models\Database;
use Illuminate\Http\JsonResponse;
use Pterodactyl\Services\Databases\DatabasePasswordService;
use Pterodactyl\Services\Databases\DatabaseManagementService;
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
use Pterodactyl\Transformers\Api\Application\ServerDatabaseTransformer;
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
use Pterodactyl\Http\Requests\Api\Application\Servers\Databases\GetServerDatabaseRequest;
@ -18,34 +17,14 @@ use Pterodactyl\Http\Requests\Api\Application\Servers\Databases\StoreServerDatab
class DatabaseController extends ApplicationApiController
{
/**
* @var \Pterodactyl\Services\Databases\DatabaseManagementService
*/
private $databaseManagementService;
/**
* @var \Pterodactyl\Services\Databases\DatabasePasswordService
*/
private $databasePasswordService;
/**
* @var \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface
*/
private $repository;
/**
* DatabaseController constructor.
*/
public function __construct(
DatabaseManagementService $databaseManagementService,
DatabasePasswordService $databasePasswordService,
DatabaseRepositoryInterface $repository
private DatabaseManagementService $databaseManagementService,
private DatabasePasswordService $databasePasswordService
) {
parent::__construct();
$this->databaseManagementService = $databaseManagementService;
$this->databasePasswordService = $databasePasswordService;
$this->repository = $repository;
}
/**

View file

@ -8,7 +8,6 @@ use Illuminate\Http\JsonResponse;
use Spatie\QueryBuilder\QueryBuilder;
use Pterodactyl\Services\Servers\ServerCreationService;
use Pterodactyl\Services\Servers\ServerDeletionService;
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
use Pterodactyl\Transformers\Api\Application\ServerTransformer;
use Pterodactyl\Http\Requests\Api\Application\Servers\GetServerRequest;
use Pterodactyl\Http\Requests\Api\Application\Servers\GetServersRequest;
@ -18,38 +17,18 @@ use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
class ServerController extends ApplicationApiController
{
/**
* @var \Pterodactyl\Services\Servers\ServerCreationService
*/
private $creationService;
/**
* @var \Pterodactyl\Services\Servers\ServerDeletionService
*/
private $deletionService;
/**
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
*/
private $repository;
/**
* ServerController constructor.
*/
public function __construct(
ServerCreationService $creationService,
ServerDeletionService $deletionService,
ServerRepositoryInterface $repository
private ServerCreationService $creationService,
private ServerDeletionService $deletionService
) {
parent::__construct();
$this->creationService = $creationService;
$this->deletionService = $deletionService;
$this->repository = $repository;
}
/**
* Return all of the servers that currently exist on the Panel.
* Return all the servers that currently exist on the Panel.
*/
public function index(GetServersRequest $request): array
{
@ -94,6 +73,8 @@ class ServerController extends ApplicationApiController
}
/**
* Deletes a server.
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function delete(ServerWriteRequest $request, Server $server, string $force = ''): Response

View file

@ -12,27 +12,14 @@ use Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerBuildConfigura
class ServerDetailsController extends ApplicationApiController
{
/**
* @var \Pterodactyl\Services\Servers\BuildModificationService
*/
private $buildModificationService;
/**
* @var \Pterodactyl\Services\Servers\DetailsModificationService
*/
private $detailsModificationService;
/**
* ServerDetailsController constructor.
*/
public function __construct(
BuildModificationService $buildModificationService,
DetailsModificationService $detailsModificationService
private BuildModificationService $buildModificationService,
private DetailsModificationService $detailsModificationService
) {
parent::__construct();
$this->buildModificationService = $buildModificationService;
$this->detailsModificationService = $detailsModificationService;
}
/**

View file

@ -12,26 +12,13 @@ use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
class ServerManagementController extends ApplicationApiController
{
/**
* @var \Pterodactyl\Services\Servers\ReinstallServerService
*/
private $reinstallServerService;
/**
* @var \Pterodactyl\Services\Servers\SuspensionService
*/
private $suspensionService;
/**
* SuspensionController constructor.
* ServerManagementController constructor.
*/
public function __construct(
ReinstallServerService $reinstallServerService,
SuspensionService $suspensionService
private ReinstallServerService $reinstallServerService,
private SuspensionService $suspensionService
) {
parent::__construct();
$this->reinstallServerService = $reinstallServerService;
$this->suspensionService = $suspensionService;
}
/**
@ -41,7 +28,7 @@ class ServerManagementController extends ApplicationApiController
*/
public function suspend(ServerWriteRequest $request, Server $server): Response
{
$this->suspensionService->toggle($server, SuspensionService::ACTION_SUSPEND);
$this->suspensionService->toggle($server);
return $this->returnNoContent();
}

View file

@ -11,19 +11,12 @@ use Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerStartupRequest
class StartupController extends ApplicationApiController
{
/**
* @var \Pterodactyl\Services\Servers\StartupModificationService
*/
private $modificationService;
/**
* StartupController constructor.
*/
public function __construct(StartupModificationService $modificationService)
public function __construct(private StartupModificationService $modificationService)
{
parent::__construct();
$this->modificationService = $modificationService;
}
/**

View file

@ -3,13 +3,11 @@
namespace Pterodactyl\Http\Controllers\Api\Application\Users;
use Pterodactyl\Models\User;
use Illuminate\Http\Response;
use Illuminate\Http\JsonResponse;
use Spatie\QueryBuilder\QueryBuilder;
use Pterodactyl\Services\Users\UserUpdateService;
use Pterodactyl\Services\Users\UserCreationService;
use Pterodactyl\Services\Users\UserDeletionService;
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
use Pterodactyl\Transformers\Api\Application\UserTransformer;
use Pterodactyl\Http\Requests\Api\Application\Users\GetUsersRequest;
use Pterodactyl\Http\Requests\Api\Application\Users\StoreUserRequest;
@ -19,41 +17,15 @@ use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
class UserController extends ApplicationApiController
{
/**
* @var \Pterodactyl\Services\Users\UserCreationService
*/
private $creationService;
/**
* @var \Pterodactyl\Services\Users\UserDeletionService
*/
private $deletionService;
/**
* @var \Pterodactyl\Contracts\Repository\UserRepositoryInterface
*/
private $repository;
/**
* @var \Pterodactyl\Services\Users\UserUpdateService
*/
private $updateService;
/**
* UserController constructor.
*/
public function __construct(
UserRepositoryInterface $repository,
UserCreationService $creationService,
UserDeletionService $deletionService,
UserUpdateService $updateService
private UserCreationService $creationService,
private UserDeletionService $deletionService,
private UserUpdateService $updateService
) {
parent::__construct();
$this->creationService = $creationService;
$this->deletionService = $deletionService;
$this->repository = $repository;
$this->updateService = $updateService;
}
/**
@ -107,7 +79,7 @@ class UserController extends ApplicationApiController
}
/**
* Store a new user on the system. Returns the created user and a HTTP/201
* Store a new user on the system. Returns the created user and an HTTP/201
* header on successful creation.
*
* @throws \Exception