-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
ServerTransformer.php
45 lines (41 loc) · 1.19 KB
/
ServerTransformer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace Pterodactyl\Transformers\Api\Client;
use Pterodactyl\Models\Server;
class ServerTransformer extends BaseClientTransformer
{
/**
* @return string
*/
public function getResourceName(): string
{
return Server::RESOURCE_NAME;
}
/**
* Transform a server model into a representation that can be returned
* to a client.
*
* @param \Pterodactyl\Models\Server $server
* @return array
*/
public function transform(Server $server): array
{
return [
'server_owner' => $this->getKey()->user_id === $server->owner_id,
'identifier' => $server->uuidShort,
'uuid' => $server->uuid,
'name' => $server->name,
'description' => $server->description,
'limits' => [
'memory' => $server->memory,
'swap' => $server->swap,
'disk' => $server->disk,
'io' => $server->io,
'cpu' => $server->cpu,
],
'feature_limits' => [
'databases' => $server->database_limit,
'allocations' => $server->allocation_limit,
],
];
}
}