api: cleanup controllers
This commit is contained in:
parent
00c42225e8
commit
f78aaea6a3
47 changed files with 323 additions and 764 deletions
|
@ -3,8 +3,8 @@
|
|||
namespace Pterodactyl\Http\Controllers\Api\Client\Servers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Pterodactyl\Models\Permission;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Pterodactyl\Repositories\Eloquent\SubuserRepository;
|
||||
|
@ -20,20 +20,9 @@ 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;
|
||||
private SubuserRepository $repository;
|
||||
private SubuserCreationService $creationService;
|
||||
private DaemonServerRepository $serverRepository;
|
||||
|
||||
/**
|
||||
* SubuserController constructor.
|
||||
|
@ -53,9 +42,9 @@ class SubuserController extends ClientApiController
|
|||
/**
|
||||
* Return the users associated with this server instance.
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
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,9 +54,9 @@ class SubuserController extends ClientApiController
|
|||
/**
|
||||
* Returns a single subuser associated with this server instance.
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function view(GetSubuserRequest $request)
|
||||
public function view(GetSubuserRequest $request): array
|
||||
{
|
||||
$subuser = $request->attributes->get('subuser');
|
||||
|
||||
|
@ -79,14 +68,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,
|
||||
|
@ -104,6 +91,7 @@ class SubuserController extends ClientApiController
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function update(UpdateSubuserRequest $request, Server $server): array
|
||||
{
|
||||
|
@ -139,10 +127,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): Response
|
||||
{
|
||||
/** @var \Pterodactyl\Models\Subuser $subuser */
|
||||
$subuser = $request->attributes->get('subuser');
|
||||
|
@ -156,7 +142,7 @@ class SubuserController extends ClientApiController
|
|||
Log::warning($exception, ['user_id' => $subuser->user_id, 'server_id' => $server->id]);
|
||||
}
|
||||
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
return $this->returnNoContent();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue