2018-01-31 02:36:59 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Controllers\Api\Application\Servers;
|
|
|
|
|
2018-03-02 01:26:11 +00:00
|
|
|
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
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* StartupController constructor.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function __construct(private StartupModificationService $modificationService)
|
2018-01-31 02:36:59 +00:00
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the startup and environment settings for a specific server.
|
|
|
|
*
|
2022-12-15 00:05:46 +00:00
|
|
|
* @throws \Throwable
|
2018-01-31 02:36:59 +00:00
|
|
|
*/
|
2022-05-22 18:10:01 +00:00
|
|
|
public function index(UpdateServerStartupRequest $request, Server $server): array
|
2018-01-31 02:36:59 +00:00
|
|
|
{
|
2018-03-02 01:26:11 +00:00
|
|
|
$server = $this->modificationService
|
|
|
|
->setUserLevel(User::USER_LEVEL_ADMIN)
|
2022-05-22 18:10:01 +00:00
|
|
|
->handle($server, $request->validated());
|
2018-01-31 02:36:59 +00:00
|
|
|
|
|
|
|
return $this->fractal->item($server)
|
2022-12-15 00:05:46 +00:00
|
|
|
->transformWith(ServerTransformer::class)
|
2018-01-31 02:36:59 +00:00
|
|
|
->toArray();
|
|
|
|
}
|
|
|
|
}
|