Correctly pass along startup variables for a server; closes #2255

This commit is contained in:
Dane Everitt 2020-08-25 19:11:25 -07:00
parent 9d95c5ab32
commit d58fd72bf5
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
4 changed files with 22 additions and 65 deletions

View file

@ -131,45 +131,6 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
return $server;
}
/**
* Return all of the server variables possible and default to the variable
* default if there is no value defined for the specific server requested.
*
* @param int $id
* @param bool $returnAsObject
* @return array|object
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getVariablesWithValues(int $id, bool $returnAsObject = false)
{
$this->getBuilder()
->with('variables', 'egg.variables')
->findOrFail($id);
try {
$instance = $this->getBuilder()->with('variables', 'egg.variables')->find($id, $this->getColumns());
} catch (ModelNotFoundException $exception) {
throw new RecordNotFoundException;
}
$data = [];
$instance->getRelation('egg')->getRelation('variables')->each(function ($item) use (&$data, $instance) {
$display = $instance->getRelation('variables')->where('variable_id', $item->id)->pluck('variable_value')->first();
$data[$item->env_variable] = $display ?? $item->default_value;
});
if ($returnAsObject) {
return (object) [
'data' => $data,
'server' => $instance,
];
}
return $data;
}
/**
* Return enough data to be used for the creation of a server via the daemon.
*