[#3896cn] Clean up code handling server suspension

This commit is contained in:
Dane Everitt 2019-11-30 15:37:13 -08:00
parent 2eee6f35d4
commit ed50259484
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
3 changed files with 45 additions and 54 deletions

View file

@ -50,15 +50,16 @@ class ServerManagementController extends ApplicationApiController
* Suspend a server on the Panel.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\Response
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function suspend(ServerWriteRequest $request): Response
public function suspend(ServerWriteRequest $request, Server $server): Response
{
$this->suspensionService->toggle($request->getModel(Server::class), SuspensionService::ACTION_SUSPEND);
$this->suspensionService->toggle($server, SuspensionService::ACTION_SUSPEND);
return $this->returnNoContent();
}
@ -67,15 +68,16 @@ class ServerManagementController extends ApplicationApiController
* Unsuspend a server on the Panel.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\Response
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function unsuspend(ServerWriteRequest $request): Response
public function unsuspend(ServerWriteRequest $request, Server $server): Response
{
$this->suspensionService->toggle($request->getModel(Server::class), SuspensionService::ACTION_UNSUSPEND);
$this->suspensionService->toggle($server, SuspensionService::ACTION_UNSUSPEND);
return $this->returnNoContent();
}
@ -84,15 +86,16 @@ class ServerManagementController extends ApplicationApiController
* Mark a server as needing to be reinstalled.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\Response
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function reinstall(ServerWriteRequest $request): Response
public function reinstall(ServerWriteRequest $request, Server $server): Response
{
$this->reinstallServerService->reinstall($request->getModel(Server::class));
$this->reinstallServerService->reinstall($server);
return $this->returnNoContent();
}
@ -101,13 +104,14 @@ class ServerManagementController extends ApplicationApiController
* Mark a server as needing its container rebuilt the next time it is started.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\Response
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
public function rebuild(ServerWriteRequest $request): Response
public function rebuild(ServerWriteRequest $request, Server $server): Response
{
$this->rebuildService->handle($request->getModel(Server::class));
$this->rebuildService->handle($server);
return $this->returnNoContent();
}