Update app/Transformers/Api/Client/ServerTransformer.php
This commit is contained in:
parent
c35257e4c1
commit
450dae6bd0
1 changed files with 28 additions and 19 deletions
|
@ -1,18 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Transformers\Api\Client;
|
||||
namespace App\Transformers\Api\Client;
|
||||
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Models\Subuser;
|
||||
use League\Fractal\Resource\Item;
|
||||
use Pterodactyl\Models\Allocation;
|
||||
use Pterodactyl\Models\Permission;
|
||||
use App\Models\Allocation;
|
||||
use App\Models\Egg;
|
||||
use App\Models\EggVariable;
|
||||
use App\Models\Permission;
|
||||
use App\Models\Server;
|
||||
use App\Models\Subuser;
|
||||
use App\Services\Servers\StartupCommandService;
|
||||
use Illuminate\Container\Container;
|
||||
use Pterodactyl\Models\EggVariable;
|
||||
use League\Fractal\Resource\Collection;
|
||||
use League\Fractal\Resource\Item;
|
||||
use League\Fractal\Resource\NullResource;
|
||||
use Pterodactyl\Services\Servers\StartupCommandService;
|
||||
|
||||
class ServerTransformer extends BaseClientTransformer
|
||||
{
|
||||
|
@ -31,14 +31,14 @@ class ServerTransformer extends BaseClientTransformer
|
|||
*/
|
||||
public function transform(Server $server): array
|
||||
{
|
||||
/** @var \Pterodactyl\Services\Servers\StartupCommandService $service */
|
||||
/** @var \App\Services\Servers\StartupCommandService $service */
|
||||
$service = Container::getInstance()->make(StartupCommandService::class);
|
||||
|
||||
$user = $this->request->user();
|
||||
|
||||
return [
|
||||
$data = [
|
||||
'server_owner' => $user->id === $server->owner_id,
|
||||
'identifier' => $server->uuidShort,
|
||||
'identifier' => $server->uuid_short,
|
||||
'internal_id' => $server->id,
|
||||
'uuid' => $server->uuid,
|
||||
'name' => $server->name,
|
||||
|
@ -46,7 +46,8 @@ class ServerTransformer extends BaseClientTransformer
|
|||
'is_node_under_maintenance' => $server->node->isUnderMaintenance(),
|
||||
'sftp_details' => [
|
||||
'ip' => $server->node->fqdn,
|
||||
'port' => $server->node->daemonSFTP,
|
||||
'alias' => $server->node->daemon_sftp_alias,
|
||||
'port' => $server->node->daemon_sftp,
|
||||
],
|
||||
'description' => $server->description,
|
||||
'limits' => [
|
||||
|
@ -56,7 +57,9 @@ class ServerTransformer extends BaseClientTransformer
|
|||
'io' => $server->io,
|
||||
'cpu' => $server->cpu,
|
||||
'threads' => $server->threads,
|
||||
'oom_disabled' => $server->oom_disabled,
|
||||
// This field is deprecated, please use "oom_killer".
|
||||
'oom_disabled' => !$server->oom_killer,
|
||||
'oom_killer' => $server->oom_killer,
|
||||
],
|
||||
'invocation' => $service->handle($server, !$user->can(Permission::ACTION_STARTUP_READ, $server)),
|
||||
'docker_image' => $server->image,
|
||||
|
@ -78,12 +81,18 @@ class ServerTransformer extends BaseClientTransformer
|
|||
'egg_id' => $server->egg_id,
|
||||
],
|
||||
];
|
||||
|
||||
if (!config('panel.editable_server_descriptions')) {
|
||||
unset($data['description']);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the allocations associated with this server.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \App\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeAllocations(Server $server): Collection
|
||||
{
|
||||
|
@ -108,7 +117,7 @@ class ServerTransformer extends BaseClientTransformer
|
|||
}
|
||||
|
||||
/**
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \App\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeVariables(Server $server): Collection|NullResource
|
||||
{
|
||||
|
@ -126,7 +135,7 @@ class ServerTransformer extends BaseClientTransformer
|
|||
/**
|
||||
* Returns the egg associated with this server.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \App\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeEgg(Server $server): Item
|
||||
{
|
||||
|
@ -136,7 +145,7 @@ class ServerTransformer extends BaseClientTransformer
|
|||
/**
|
||||
* Returns the subusers associated with this server.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
* @throws \App\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeSubusers(Server $server): Collection|NullResource
|
||||
{
|
||||
|
@ -146,4 +155,4 @@ class ServerTransformer extends BaseClientTransformer
|
|||
|
||||
return $this->collection($server->subusers, $this->makeTransformer(SubuserTransformer::class), Subuser::RESOURCE_NAME);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue