50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Pterodactyl\Http\Controllers\Api\Application\Servers;
|
|
|
|
use Pterodactyl\Models\User;
|
|
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
|
|
{
|
|
/**
|
|
* @var \Pterodactyl\Services\Servers\StartupModificationService
|
|
*/
|
|
private $modificationService;
|
|
|
|
/**
|
|
* StartupController constructor.
|
|
*
|
|
* @param \Pterodactyl\Services\Servers\StartupModificationService $modificationService
|
|
*/
|
|
public function __construct(StartupModificationService $modificationService)
|
|
{
|
|
parent::__construct();
|
|
|
|
$this->modificationService = $modificationService;
|
|
}
|
|
|
|
/**
|
|
* Update the startup and environment settings for a specific server.
|
|
*
|
|
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerStartupRequest $request
|
|
* @param \Pterodactyl\Models\Server $server
|
|
*
|
|
* @return array
|
|
* @throws \Throwable
|
|
*/
|
|
public function index(UpdateServerStartupRequest $request, Server $server): array
|
|
{
|
|
$server = $this->modificationService
|
|
->setUserLevel(User::USER_LEVEL_ADMIN)
|
|
->handle($server, $request->validated());
|
|
|
|
return $this->fractal->item($server)
|
|
->transformWith($this->getTransformer(ServerTransformer::class))
|
|
->toArray();
|
|
}
|
|
}
|