mirror of
https://github.com/pterodactyl/panel.git
synced 2026-12-04 05:15:41 -05:00
Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co> Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
This commit is contained in:
co-authored by
Anthony
Sky Mulley
parent
98079a0166
commit
6c0413e39b
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pterodactyl\Actions\Eggs\Scripts;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Pterodactyl\Contracts\Eggs\UpdatesEggInstallScripts;
|
||||
use Pterodactyl\Exceptions\Service\Egg\InvalidCopyFromException;
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Pterodactyl\Support\JsonValueGuard;
|
||||
|
||||
final class UpdateInstallScript implements UpdatesEggInstallScripts
|
||||
{
|
||||
/**
|
||||
* Modify the install script for a given Egg.
|
||||
*
|
||||
* @param ModelAttributes $data validated install script attributes
|
||||
*
|
||||
* @throws InvalidCopyFromException
|
||||
*/
|
||||
public function update(Egg $egg, array $data): void
|
||||
{
|
||||
$copyFrom = JsonValueGuard::nullableInteger(Arr::get($data, 'copy_script_from'));
|
||||
if ($copyFrom !== null && ! Egg::query()->scriptSources()->whereKey($copyFrom)->exists()) {
|
||||
throw new InvalidCopyFromException(trans('exceptions.egg.invalid_copy_id'));
|
||||
}
|
||||
|
||||
$egg->update([
|
||||
'script_install' => JsonValueGuard::nullableString(Arr::get($data, 'script_install')),
|
||||
'script_is_privileged' => JsonValueGuard::boolean(Arr::get($data, 'script_is_privileged', true)),
|
||||
'script_entry' => JsonValueGuard::string(Arr::get($data, 'script_entry')),
|
||||
'script_container' => JsonValueGuard::string(Arr::get($data, 'script_container')),
|
||||
'copy_script_from' => $copyFrom,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user