Path: blob/1.0-develop/app/Services/Eggs/Scripts/InstallScriptService.php
10287 views
<?php12namespace Pterodactyl\Services\Eggs\Scripts;34use Pterodactyl\Models\Egg;5use Pterodactyl\Contracts\Repository\EggRepositoryInterface;6use Pterodactyl\Exceptions\Service\Egg\InvalidCopyFromException;78class InstallScriptService9{10/**11* InstallScriptService constructor.12*/13public function __construct(protected EggRepositoryInterface $repository)14{15}1617/**18* Modify the install script for a given Egg.19*20* @throws \Pterodactyl\Exceptions\Model\DataValidationException21* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException22* @throws InvalidCopyFromException23*/24public function handle(Egg $egg, array $data): void25{26if (!is_null(array_get($data, 'copy_script_from'))) {27if (!$this->repository->isCopyableScript(array_get($data, 'copy_script_from'), $egg->nest_id)) {28throw new InvalidCopyFromException(trans('exceptions.nest.egg.invalid_copy_id'));29}30}3132$this->repository->withoutFreshModel()->update($egg->id, [33'script_install' => array_get($data, 'script_install'),34'script_is_privileged' => array_get($data, 'script_is_privileged', 1),35'script_entry' => array_get($data, 'script_entry'),36'script_container' => array_get($data, 'script_container'),37'copy_script_from' => array_get($data, 'copy_script_from'),38]);39}40}414243