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

@ -21,42 +21,21 @@ use Pterodactyl\Http\Requests\Api\Client\Servers\Subusers\UpdateSubuserRequest;
class SubuserController extends ClientApiController
{
/**
* @var \Pterodactyl\Repositories\Eloquent\SubuserRepository
*/
private $repository;
/**
* @var \Pterodactyl\Services\Subusers\SubuserCreationService
*/
private $creationService;
/**
* @var \Pterodactyl\Repositories\Wings\DaemonServerRepository
*/
private $serverRepository;
/**
* SubuserController constructor.
*/
public function __construct(
SubuserRepository $repository,
SubuserCreationService $creationService,
DaemonServerRepository $serverRepository
private SubuserRepository $repository,
private SubuserCreationService $creationService,
private DaemonServerRepository $serverRepository
) {
parent::__construct();
$this->repository = $repository;
$this->creationService = $creationService;
$this->serverRepository = $serverRepository;
}
/**
* Return the users associated with this server instance.
*
* @return array
*/
public function index(GetSubuserRequest $request, Server $server)
public function index(GetSubuserRequest $request, Server $server): array
{
return $this->fractal->collection($server->subusers)
->transformWith($this->getTransformer(SubuserTransformer::class))
@ -65,10 +44,8 @@ class SubuserController extends ClientApiController
/**
* Returns a single subuser associated with this server instance.
*
* @return array
*/
public function view(GetSubuserRequest $request)
public function view(GetSubuserRequest $request): array
{
$subuser = $request->attributes->get('subuser');
@ -80,14 +57,12 @@ class SubuserController extends ClientApiController
/**
* Create a new subuser for the given server.
*
* @return array
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Service\Subuser\ServerSubuserExistsException
* @throws \Pterodactyl\Exceptions\Service\Subuser\UserIsServerOwnerException
* @throws \Throwable
*/
public function store(StoreSubuserRequest $request, Server $server)
public function store(StoreSubuserRequest $request, Server $server): array
{
$response = $this->creationService->handle(
$server,
@ -143,7 +118,7 @@ class SubuserController extends ClientApiController
$this->serverRepository->setServer($server)->revokeUserJTI($subuser->user_id);
} catch (DaemonConnectionException $exception) {
// Don't block this request if we can't connect to the Wings instance. Chances are it is
// offline in this event and the token will be invalid anyways once Wings boots back.
// offline and the token will be invalid once Wings boots back.
Log::warning($exception, ['user_id' => $subuser->user_id, 'server_id' => $server->id]);
$instance->property('revoked', false);
@ -160,10 +135,8 @@ class SubuserController extends ClientApiController
/**
* Removes a subusers from a server's assignment.
*
* @return \Illuminate\Http\JsonResponse
*/
public function delete(DeleteSubuserRequest $request, Server $server)
public function delete(DeleteSubuserRequest $request, Server $server): JsonResponse
{
/** @var \Pterodactyl\Models\Subuser $subuser */
$subuser = $request->attributes->get('subuser');