misc_pterodactyl-panel/app/Http/Controllers/Api/Application/Servers/StartupController.php

42 lines
1.3 KiB
PHP
Raw Normal View History

2018-01-31 02:36:59 +00:00
<?php
namespace Pterodactyl\Http\Controllers\Api\Application\Servers;
use Pterodactyl\Models\User;
2018-01-31 02:36:59 +00:00
use Pterodactyl\Models\Server;
use Pterodactyl\Services\Servers\StartupModificationService;
use Pterodactyl\Transformers\Api\Application\ServerTransformer;
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
use Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerStartupRequest;
class StartupController extends ApplicationApiController
{
2021-03-05 17:03:12 +00:00
private StartupModificationService $modificationService;
2018-01-31 02:36:59 +00:00
/**
* StartupController constructor.
*/
public function __construct(StartupModificationService $modificationService)
{
parent::__construct();
$this->modificationService = $modificationService;
}
/**
* Update the startup and environment settings for a specific server.
*
2021-03-05 17:03:12 +00:00
* @throws \Throwable
2018-01-31 02:36:59 +00:00
*/
public function index(UpdateServerStartupRequest $request, Server $server): array
2018-01-31 02:36:59 +00:00
{
$server = $this->modificationService
->setUserLevel(User::USER_LEVEL_ADMIN)
->handle($server, $request->validated());
2018-01-31 02:36:59 +00:00
return $this->fractal->item($server)
->transformWith($this->getTransformer(ServerTransformer::class))
->toArray();
}
}