Path: blob/1.0-develop/app/Services/Eggs/Sharing/EggExporterService.php
10311 views
<?php12namespace Pterodactyl\Services\Eggs\Sharing;34use Carbon\Carbon;5use Pterodactyl\Models\Egg;6use Illuminate\Support\Collection;7use Pterodactyl\Models\EggVariable;8use Pterodactyl\Contracts\Repository\EggRepositoryInterface;910class EggExporterService11{12/**13* EggExporterService constructor.14*/15public function __construct(protected EggRepositoryInterface $repository)16{17}1819/**20* Return a JSON representation of an egg and its variables.21*22* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException23*/24public function handle(int $egg): string25{26$egg = $this->repository->getWithExportAttributes($egg);2728$struct = [29'_comment' => 'DO NOT EDIT: FILE GENERATED AUTOMATICALLY BY PTERODACTYL PANEL - PTERODACTYL.IO',30'meta' => [31'version' => Egg::EXPORT_VERSION,32'update_url' => $egg->update_url,33],34'exported_at' => Carbon::now()->toAtomString(),35'name' => $egg->name,36'author' => $egg->author,37'description' => $egg->description,38'features' => $egg->features,39'docker_images' => $egg->docker_images,40'file_denylist' => Collection::make($egg->inherit_file_denylist)->filter(function ($value) {41return !empty($value);42}),43'startup' => $egg->startup,44'config' => [45'files' => $egg->inherit_config_files,46'startup' => $egg->inherit_config_startup,47'logs' => $egg->inherit_config_logs,48'stop' => $egg->inherit_config_stop,49],50'scripts' => [51'installation' => [52'script' => $egg->copy_script_install,53'container' => $egg->copy_script_container,54'entrypoint' => $egg->copy_script_entry,55],56],57'variables' => $egg->variables->transform(function (EggVariable $item) {58return Collection::make($item->toArray())59->except(['id', 'egg_id', 'created_at', 'updated_at'])60->merge(['field_type' => 'text'])61->toArray();62}),63];6465return json_encode($struct, JSON_PRETTY_PRINT);66}67}686970