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
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
* @return array
|
|
|
|
*
|
|
|
|
* @throws \Illuminate\Validation\ValidationException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
|
|
*/
|
|
|
|
public function index(UpdateServerStartupRequest $request): array
|
|
|
|
{
|
2018-03-02 01:26:11 +00:00
|
|
|
$server = $this->modificationService
|
|
|
|
->setUserLevel(User::USER_LEVEL_ADMIN)
|
|
|
|
->handle($request->getModel(Server::class), $request->validated());
|
2018-01-31 02:36:59 +00:00
|
|
|
|
|
|
|
return $this->fractal->item($server)
|
|
|
|
->transformWith($this->getTransformer(ServerTransformer::class))
|
|
|
|
->toArray();
|
|
|
|
}
|
|
|
|
}
|