Files

53 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2018-01-30 20:36:59 -06:00
<?php
2026-10-05 18:10:18 -04:00
declare(strict_types=1);
2018-01-30 20:36:59 -06:00
namespace Pterodactyl\Http\Requests\Api\Application\Servers;
2026-10-11 09:09:51 -04:00
use Pterodactyl\Actions\Servers\UpdateServerStartup;
2026-10-05 18:10:18 -04:00
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
2026-10-11 09:09:51 -04:00
use Pterodactyl\Models\User;
2018-01-30 20:36:59 -06:00
use Pterodactyl\Services\Acl\Api\AdminAcl;
class UpdateServerStartupRequest extends ApplicationApiRequest
{
2022-10-14 10:59:20 -06:00
protected ?string $resource = AdminAcl::RESOURCE_SERVERS;
2018-01-30 20:36:59 -06:00
2022-10-14 10:59:20 -06:00
protected int $permission = AdminAcl::WRITE;
2018-01-30 20:36:59 -06:00
/**
2026-10-11 09:09:51 -04:00
* Validation rules to run the input against. The Application API keeps its own field
* names; actionInput() hands the values to the action under its names.
2026-10-05 18:10:18 -04:00
*
* @return ValidationRules
2018-01-30 20:36:59 -06:00
*/
public function rules(): array
{
2026-10-11 09:09:51 -04:00
$rules = UpdateServerStartup::rules(User::USER_LEVEL_ADMIN);
2018-01-30 20:36:59 -06:00
return [
2026-10-11 09:09:51 -04:00
'startup' => $rules['startup'],
'environment' => $rules['environment'],
'egg' => $rules['egg_id'],
'image' => $rules['docker_image'],
'skip_scripts' => $rules['skip_scripts'],
2018-01-30 20:36:59 -06:00
];
}
/**
2026-10-11 09:09:51 -04:00
* The validated input under the action's field names: egg and image are its egg_id
* and docker_image.
2026-10-05 18:10:18 -04:00
*
2026-10-11 19:54:55 -04:00
* @return array<string, mixed>
2018-01-30 20:36:59 -06:00
*/
2026-10-11 09:09:51 -04:00
public function actionInput(): array
2018-01-30 20:36:59 -06:00
{
2026-10-11 09:09:51 -04:00
$input = parent::actionInput();
$input['egg_id'] = $input['egg'] ?? null;
$input['docker_image'] = $input['image'] ?? null;
unset($input['egg'], $input['image']);
return $input;
2018-01-30 20:36:59 -06:00
}
}