Correctly pass along startup variables for a server; closes #2255
This commit is contained in:
parent
9d95c5ab32
commit
d58fd72bf5
4 changed files with 22 additions and 65 deletions
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue