Use more standardized phpcs
This commit is contained in:
parent
a043071e3c
commit
c449ca5155
493 changed files with 1116 additions and 3903 deletions
|
@ -18,8 +18,6 @@ class AllocationTransformer extends BaseTransformer
|
|||
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
|
@ -29,7 +27,6 @@ class AllocationTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return a generic transformed allocation array.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Allocation $allocation
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Allocation $allocation)
|
||||
|
@ -40,43 +37,47 @@ class AllocationTransformer extends BaseTransformer
|
|||
'alias' => $allocation->ip_alias,
|
||||
'port' => $allocation->port,
|
||||
'notes' => $allocation->notes,
|
||||
'assigned' => ! is_null($allocation->server_id),
|
||||
'assigned' => !is_null($allocation->server_id),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the node relationship onto a given transformation.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Allocation $allocation
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeNode(Allocation $allocation)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_NODES)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_NODES)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
return $this->item(
|
||||
$allocation->node, $this->makeTransformer(NodeTransformer::class), Node::RESOURCE_NAME
|
||||
$allocation->node,
|
||||
$this->makeTransformer(NodeTransformer::class),
|
||||
Node::RESOURCE_NAME
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the server relationship onto a given transformation.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Allocation $allocation
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeServer(Allocation $allocation)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_SERVERS) || ! $allocation->server) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_SERVERS) || !$allocation->server) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
return $this->item(
|
||||
$allocation->server, $this->makeTransformer(ServerTransformer::class), Server::RESOURCE_NAME
|
||||
$allocation->server,
|
||||
$this->makeTransformer(ServerTransformer::class),
|
||||
Server::RESOURCE_NAME
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ use Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException;
|
|||
*/
|
||||
abstract class BaseTransformer extends TransformerAbstract
|
||||
{
|
||||
const RESPONSE_TIMEZONE = 'UTC';
|
||||
public const RESPONSE_TIMEZONE = 'UTC';
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Models\ApiKey
|
||||
|
@ -24,8 +24,6 @@ abstract class BaseTransformer extends TransformerAbstract
|
|||
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract public function getResourceName(): string;
|
||||
|
||||
|
@ -43,7 +41,6 @@ abstract class BaseTransformer extends TransformerAbstract
|
|||
/**
|
||||
* Set the HTTP request class being used for this request.
|
||||
*
|
||||
* @param \Pterodactyl\Models\ApiKey $key
|
||||
* @return $this
|
||||
*/
|
||||
public function setKey(ApiKey $key)
|
||||
|
@ -55,8 +52,6 @@ abstract class BaseTransformer extends TransformerAbstract
|
|||
|
||||
/**
|
||||
* Return the request instance being used for this transformer.
|
||||
*
|
||||
* @return \Pterodactyl\Models\ApiKey
|
||||
*/
|
||||
public function getKey(): ApiKey
|
||||
{
|
||||
|
@ -67,9 +62,6 @@ abstract class BaseTransformer extends TransformerAbstract
|
|||
* Determine if the API key loaded onto the transformer has permission
|
||||
* to access a different resource. This is used when including other
|
||||
* models on a transformation request.
|
||||
*
|
||||
* @param string $resource
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorize(string $resource): bool
|
||||
{
|
||||
|
@ -80,8 +72,6 @@ abstract class BaseTransformer extends TransformerAbstract
|
|||
* Create a new instance of the transformer and pass along the currently
|
||||
* set API key.
|
||||
*
|
||||
* @param string $abstract
|
||||
* @param array $parameters
|
||||
* @return \Pterodactyl\Transformers\Api\Application\BaseTransformer
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
|
@ -92,7 +82,7 @@ abstract class BaseTransformer extends TransformerAbstract
|
|||
$transformer = Container::getInstance()->makeWith($abstract, $parameters);
|
||||
$transformer->setKey($this->getKey());
|
||||
|
||||
if (! $transformer instanceof self) {
|
||||
if (!$transformer instanceof self) {
|
||||
throw new InvalidTransformerLevelException('Calls to ' . __METHOD__ . ' must return a transformer that is an instance of ' . __CLASS__);
|
||||
}
|
||||
|
||||
|
@ -101,9 +91,6 @@ abstract class BaseTransformer extends TransformerAbstract
|
|||
|
||||
/**
|
||||
* Return an ISO-8601 formatted timestamp to use in the API response.
|
||||
*
|
||||
* @param string $timestamp
|
||||
* @return string
|
||||
*/
|
||||
protected function formatTimestamp(string $timestamp): string
|
||||
{
|
||||
|
|
|
@ -17,8 +17,6 @@ class DatabaseHostTransformer extends BaseTransformer
|
|||
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
|
@ -28,7 +26,6 @@ class DatabaseHostTransformer extends BaseTransformer
|
|||
/**
|
||||
* Transform database host into a representation for the application API.
|
||||
*
|
||||
* @param \Pterodactyl\Models\DatabaseHost $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(DatabaseHost $model)
|
||||
|
@ -48,13 +45,13 @@ class DatabaseHostTransformer extends BaseTransformer
|
|||
/**
|
||||
* Include the databases associated with this host.
|
||||
*
|
||||
* @param \Pterodactyl\Models\DatabaseHost $model
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeDatabases(DatabaseHost $model)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_SERVER_DATABASES)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_SERVER_DATABASES)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,8 +21,6 @@ class EggTransformer extends BaseTransformer
|
|||
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
|
@ -33,7 +31,6 @@ class EggTransformer extends BaseTransformer
|
|||
* Transform an Egg model into a representation that can be consumed by
|
||||
* the application api.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Egg $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Egg $model)
|
||||
|
@ -74,13 +71,13 @@ class EggTransformer extends BaseTransformer
|
|||
/**
|
||||
* Include the Nest relationship for the given Egg in the transformation.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Egg $model
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeNest(Egg $model)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_NESTS)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_NESTS)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
@ -92,13 +89,13 @@ class EggTransformer extends BaseTransformer
|
|||
/**
|
||||
* Include the Servers relationship for the given Egg in the transformation.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Egg $model
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeServers(Egg $model)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
@ -111,7 +108,6 @@ class EggTransformer extends BaseTransformer
|
|||
* Include more detailed information about the configuration if this Egg is
|
||||
* extending another.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Egg $model
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*/
|
||||
public function includeConfig(Egg $model)
|
||||
|
@ -136,7 +132,6 @@ class EggTransformer extends BaseTransformer
|
|||
* Include more detailed information about the script configuration if the
|
||||
* Egg is extending another.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Egg $model
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*/
|
||||
public function includeScript(Egg $model)
|
||||
|
@ -160,13 +155,13 @@ class EggTransformer extends BaseTransformer
|
|||
/**
|
||||
* Include the variables that are defined for this Egg.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Egg $model
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeVariables(Egg $model)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_EGGS)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_EGGS)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,6 @@ class EggVariableTransformer extends BaseTransformer
|
|||
{
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
|
|
|
@ -16,8 +16,6 @@ class LocationTransformer extends BaseTransformer
|
|||
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
|
@ -26,9 +24,6 @@ class LocationTransformer extends BaseTransformer
|
|||
|
||||
/**
|
||||
* Return a generic transformed location array.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Location $location
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Location $location): array
|
||||
{
|
||||
|
@ -44,14 +39,13 @@ class LocationTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return the nodes associated with this location.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Location $location
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeServers(Location $location)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
@ -63,14 +57,13 @@ class LocationTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return the nodes associated with this location.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Location $location
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeNodes(Location $location)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_NODES)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_NODES)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@ class NestTransformer extends BaseTransformer
|
|||
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
|
@ -32,7 +30,6 @@ class NestTransformer extends BaseTransformer
|
|||
* Transform a Nest model into a representation that can be consumed by the
|
||||
* application API.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Nest $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Nest $model)
|
||||
|
@ -48,14 +45,13 @@ class NestTransformer extends BaseTransformer
|
|||
/**
|
||||
* Include the Eggs relationship on the given Nest model transformation.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Nest $model
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeEggs(Nest $model)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_EGGS)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_EGGS)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
@ -67,14 +63,13 @@ class NestTransformer extends BaseTransformer
|
|||
/**
|
||||
* Include the servers relationship on the given Nest model.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Nest $model
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeServers(Nest $model)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@ class NodeTransformer extends BaseTransformer
|
|||
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
|
@ -27,9 +25,6 @@ class NodeTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return a node transformed into a format that can be consumed by the
|
||||
* external administrative API.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Node $node): array
|
||||
{
|
||||
|
@ -57,60 +52,66 @@ class NodeTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return the nodes associated with this location.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeAllocations(Node $node)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_ALLOCATIONS)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_ALLOCATIONS)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
$node->loadMissing('allocations');
|
||||
|
||||
return $this->collection(
|
||||
$node->getRelation('allocations'), $this->makeTransformer(AllocationTransformer::class), 'allocation'
|
||||
$node->getRelation('allocations'),
|
||||
$this->makeTransformer(AllocationTransformer::class),
|
||||
'allocation'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the nodes associated with this location.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeLocation(Node $node)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_LOCATIONS)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_LOCATIONS)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
$node->loadMissing('location');
|
||||
|
||||
return $this->item(
|
||||
$node->getRelation('location'), $this->makeTransformer(LocationTransformer::class), 'location'
|
||||
$node->getRelation('location'),
|
||||
$this->makeTransformer(LocationTransformer::class),
|
||||
'location'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the nodes associated with this location.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeServers(Node $node)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
$node->loadMissing('servers');
|
||||
|
||||
return $this->collection(
|
||||
$node->getRelation('servers'), $this->makeTransformer(ServerTransformer::class), 'server'
|
||||
$node->getRelation('servers'),
|
||||
$this->makeTransformer(ServerTransformer::class),
|
||||
'server'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,6 @@ class ServerDatabaseTransformer extends BaseTransformer
|
|||
|
||||
/**
|
||||
* Perform dependency injection.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
|
||||
*/
|
||||
public function handle(Encrypter $encrypter)
|
||||
{
|
||||
|
@ -31,8 +29,6 @@ class ServerDatabaseTransformer extends BaseTransformer
|
|||
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
|
@ -41,9 +37,6 @@ class ServerDatabaseTransformer extends BaseTransformer
|
|||
|
||||
/**
|
||||
* Transform a database model in a representation for the application API.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Database $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Database $model): array
|
||||
{
|
||||
|
@ -63,7 +56,6 @@ class ServerDatabaseTransformer extends BaseTransformer
|
|||
/**
|
||||
* Include the database password in the request.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Database $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
*/
|
||||
public function includePassword(Database $model)
|
||||
|
@ -78,13 +70,13 @@ class ServerDatabaseTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return the database host relationship for this server database.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Database $model
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeHost(Database $model)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_DATABASE_HOSTS)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_DATABASE_HOSTS)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,6 @@ class ServerTransformer extends BaseTransformer
|
|||
|
||||
/**
|
||||
* Perform dependency injection.
|
||||
*
|
||||
* @param \Pterodactyl\Services\Servers\EnvironmentService $environmentService
|
||||
*/
|
||||
public function handle(EnvironmentService $environmentService)
|
||||
{
|
||||
|
@ -43,8 +41,6 @@ class ServerTransformer extends BaseTransformer
|
|||
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
|
@ -53,9 +49,6 @@ class ServerTransformer extends BaseTransformer
|
|||
|
||||
/**
|
||||
* Return a generic transformed server array.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Server $server): array
|
||||
{
|
||||
|
@ -99,14 +92,13 @@ class ServerTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return a generic array of allocations for this server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeAllocations(Server $server)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_ALLOCATIONS)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_ALLOCATIONS)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
@ -118,14 +110,13 @@ class ServerTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return a generic array of data about subusers for this server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeSubusers(Server $server)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_USERS)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_USERS)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
@ -137,14 +128,13 @@ class ServerTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return a generic array of data about subusers for this server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeUser(Server $server)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_USERS)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_USERS)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
@ -156,14 +146,13 @@ class ServerTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return a generic array with nest information for this server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeNest(Server $server)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_NESTS)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_NESTS)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
@ -175,14 +164,13 @@ class ServerTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return a generic array with egg information for this server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeEgg(Server $server)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_EGGS)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_EGGS)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
@ -194,14 +182,13 @@ class ServerTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return a generic array of data about subusers for this server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeVariables(Server $server)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
@ -213,14 +200,13 @@ class ServerTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return a generic array with location information for this server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeLocation(Server $server)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_LOCATIONS)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_LOCATIONS)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
@ -232,14 +218,13 @@ class ServerTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return a generic array with node information for this server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeNode(Server $server)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_NODES)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_NODES)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
@ -251,14 +236,13 @@ class ServerTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return a generic array with database information for this server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeDatabases(Server $server)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_SERVER_DATABASES)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_SERVER_DATABASES)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@ class ServerVariableTransformer extends BaseTransformer
|
|||
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
|
@ -27,7 +25,6 @@ class ServerVariableTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return a generic transformed server variable array.
|
||||
*
|
||||
* @param \Pterodactyl\Models\EggVariable $variable
|
||||
* @return array
|
||||
*/
|
||||
public function transform(EggVariable $variable)
|
||||
|
@ -38,13 +35,13 @@ class ServerVariableTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return the parent service variable data.
|
||||
*
|
||||
* @param \Pterodactyl\Models\EggVariable $variable
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeParent(EggVariable $variable)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_EGGS)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_EGGS)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@ class SubuserTransformer extends BaseTransformer
|
|||
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
|
@ -26,9 +24,6 @@ class SubuserTransformer extends BaseTransformer
|
|||
|
||||
/**
|
||||
* Return a transformed Subuser model that can be consumed by external services.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Subuser $subuser
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Subuser $subuser): array
|
||||
{
|
||||
|
@ -45,14 +40,13 @@ class SubuserTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return a generic item of user for this subuser.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Subuser $subuser
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeUser(Subuser $subuser)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_USERS)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_USERS)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
@ -64,14 +58,13 @@ class SubuserTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return a generic item of server for this subuser.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Subuser $subuser
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeServer(Subuser $subuser)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@ class UserTransformer extends BaseTransformer
|
|||
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
|
@ -26,9 +24,6 @@ class UserTransformer extends BaseTransformer
|
|||
|
||||
/**
|
||||
* Return a transformed User model that can be consumed by external services.
|
||||
*
|
||||
* @param \Pterodactyl\Models\User $user
|
||||
* @return array
|
||||
*/
|
||||
public function transform(User $user): array
|
||||
{
|
||||
|
@ -51,14 +46,13 @@ class UserTransformer extends BaseTransformer
|
|||
/**
|
||||
* Return the servers associated with this user.
|
||||
*
|
||||
* @param \Pterodactyl\Models\User $user
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeServers(User $user)
|
||||
{
|
||||
if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) {
|
||||
if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@ class AccountTransformer extends BaseClientTransformer
|
|||
{
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
|
@ -19,7 +17,6 @@ class AccountTransformer extends BaseClientTransformer
|
|||
/**
|
||||
* Return basic information about the currently logged in user.
|
||||
*
|
||||
* @param \Pterodactyl\Models\User $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(User $model)
|
||||
|
|
|
@ -8,8 +8,6 @@ class AllocationTransformer extends BaseClientTransformer
|
|||
{
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
|
@ -19,7 +17,6 @@ class AllocationTransformer extends BaseClientTransformer
|
|||
/**
|
||||
* Return basic information about the currently logged in user.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Allocation $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Allocation $model)
|
||||
|
|
|
@ -17,7 +17,6 @@ class ApiKeyTransformer extends BaseClientTransformer
|
|||
/**
|
||||
* Transform this model into a representation that can be consumed by a client.
|
||||
*
|
||||
* @param \Pterodactyl\Models\ApiKey $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(ApiKey $model)
|
||||
|
|
|
@ -6,16 +6,12 @@ use Pterodactyl\Models\Backup;
|
|||
|
||||
class BackupTransformer extends BaseClientTransformer
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
return Backup::RESOURCE_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Pterodactyl\Models\Backup $backup
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Backup $backup)
|
||||
|
|
|
@ -18,8 +18,6 @@ abstract class BaseClientTransformer extends BaseApplicationTransformer
|
|||
|
||||
/**
|
||||
* Return the user model of the user requesting this transformation.
|
||||
*
|
||||
* @return \Pterodactyl\Models\User
|
||||
*/
|
||||
public function getUser(): User
|
||||
{
|
||||
|
@ -28,8 +26,6 @@ abstract class BaseClientTransformer extends BaseApplicationTransformer
|
|||
|
||||
/**
|
||||
* Set the user model of the user requesting this transformation.
|
||||
*
|
||||
* @param \Pterodactyl\Models\User $user
|
||||
*/
|
||||
public function setUser(User $user)
|
||||
{
|
||||
|
@ -41,9 +37,7 @@ abstract class BaseClientTransformer extends BaseApplicationTransformer
|
|||
* to access a different resource. This is used when including other
|
||||
* models on a transformation request.
|
||||
*
|
||||
* @param string $ability
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorize(string $ability, Server $server = null): bool
|
||||
{
|
||||
|
@ -56,8 +50,6 @@ abstract class BaseClientTransformer extends BaseApplicationTransformer
|
|||
* Create a new instance of the transformer and pass along the currently
|
||||
* set API key.
|
||||
*
|
||||
* @param string $abstract
|
||||
* @param array $parameters
|
||||
* @return self
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
|
@ -68,7 +60,7 @@ abstract class BaseClientTransformer extends BaseApplicationTransformer
|
|||
$transformer = Container::getInstance()->makeWith($abstract, $parameters);
|
||||
$transformer->setKey($this->getKey());
|
||||
|
||||
if (! $transformer instanceof self) {
|
||||
if (!$transformer instanceof self) {
|
||||
throw new InvalidTransformerLevelException('Calls to ' . __METHOD__ . ' must return a transformer that is an instance of ' . __CLASS__);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,9 +23,6 @@ class DatabaseTransformer extends BaseClientTransformer
|
|||
|
||||
/**
|
||||
* Handle dependency injection.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
|
||||
* @param \Pterodactyl\Contracts\Extensions\HashidsInterface $hashids
|
||||
*/
|
||||
public function handle(Encrypter $encrypter, HashidsInterface $hashids)
|
||||
{
|
||||
|
@ -33,18 +30,11 @@ class DatabaseTransformer extends BaseClientTransformer
|
|||
$this->hashids = $hashids;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
return Database::RESOURCE_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Pterodactyl\Models\Database $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Database $model): array
|
||||
{
|
||||
$model->loadMissing('host');
|
||||
|
@ -65,12 +55,11 @@ class DatabaseTransformer extends BaseClientTransformer
|
|||
/**
|
||||
* Include the database password in the request.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Database $database
|
||||
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
|
||||
*/
|
||||
public function includePassword(Database $database)
|
||||
{
|
||||
if (! $this->getUser()->can(Permission::ACTION_DATABASE_VIEW_PASSWORD, $database->server)) {
|
||||
if (!$this->getUser()->can(Permission::ACTION_DATABASE_VIEW_PASSWORD, $database->server)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@ class EggTransformer extends BaseClientTransformer
|
|||
{
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
|
@ -17,7 +15,6 @@ class EggTransformer extends BaseClientTransformer
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Pterodactyl\Models\Egg $egg
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Egg $egg)
|
||||
|
|
|
@ -7,16 +7,12 @@ use Pterodactyl\Models\EggVariable;
|
|||
|
||||
class EggVariableTransformer extends BaseClientTransformer
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
return EggVariable::RESOURCE_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Pterodactyl\Models\EggVariable $variable
|
||||
* @return array
|
||||
*/
|
||||
public function transform(EggVariable $variable)
|
||||
|
@ -24,10 +20,8 @@ class EggVariableTransformer extends BaseClientTransformer
|
|||
// This guards against someone incorrectly retrieving variables (haha, me) and then passing
|
||||
// them into the transformer and along to the user. Just throw an exception and break the entire
|
||||
// pathway since you should never be exposing these types of variables to a client.
|
||||
if (! $variable->user_viewable) {
|
||||
throw new BadMethodCallException(
|
||||
'Cannot transform a hidden egg variable in a client transformer.'
|
||||
);
|
||||
if (!$variable->user_viewable) {
|
||||
throw new BadMethodCallException('Cannot transform a hidden egg variable in a client transformer.');
|
||||
}
|
||||
|
||||
return [
|
||||
|
|
|
@ -29,7 +29,6 @@ class ScheduleTransformer extends BaseClientTransformer
|
|||
/**
|
||||
* Returns a transformed schedule model such that a client can view the information.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Schedule $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Schedule $model)
|
||||
|
@ -56,7 +55,6 @@ class ScheduleTransformer extends BaseClientTransformer
|
|||
/**
|
||||
* Allows attaching the tasks specific to the schedule in the response.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Schedule $model
|
||||
* @return \League\Fractal\Resource\Collection
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
|
@ -64,7 +62,9 @@ class ScheduleTransformer extends BaseClientTransformer
|
|||
public function includeTasks(Schedule $model)
|
||||
{
|
||||
return $this->collection(
|
||||
$model->tasks, $this->makeTransformer(TaskTransformer::class), Task::RESOURCE_NAME
|
||||
$model->tasks,
|
||||
$this->makeTransformer(TaskTransformer::class),
|
||||
Task::RESOURCE_NAME
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,9 +23,6 @@ class ServerTransformer extends BaseClientTransformer
|
|||
*/
|
||||
protected $availableIncludes = ['egg', 'subusers'];
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
return Server::RESOURCE_NAME;
|
||||
|
@ -34,9 +31,6 @@ class ServerTransformer extends BaseClientTransformer
|
|||
/**
|
||||
* 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
|
||||
{
|
||||
|
@ -62,7 +56,7 @@ class ServerTransformer extends BaseClientTransformer
|
|||
'io' => $server->io,
|
||||
'cpu' => $server->cpu,
|
||||
],
|
||||
'invocation' => $service->handle($server, ! $this->getUser()->can(Permission::ACTION_STARTUP_READ, $server)),
|
||||
'invocation' => $service->handle($server, !$this->getUser()->can(Permission::ACTION_STARTUP_READ, $server)),
|
||||
'docker_image' => $server->image,
|
||||
'egg_features' => $server->egg->inherit_features,
|
||||
'feature_limits' => [
|
||||
|
@ -72,14 +66,13 @@ class ServerTransformer extends BaseClientTransformer
|
|||
],
|
||||
'is_suspended' => $server->suspended,
|
||||
'is_installing' => $server->installed !== 1,
|
||||
'is_transferring' => ! is_null($server->transfer),
|
||||
'is_transferring' => !is_null($server->transfer),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the allocations associated with this server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
|
@ -95,7 +88,7 @@ class ServerTransformer extends BaseClientTransformer
|
|||
//
|
||||
// This allows us to avoid too much permission regression, without also hiding information that
|
||||
// is generally needed for the frontend to make sense when browsing or searching results.
|
||||
if (! $this->getUser()->can(Permission::ACTION_ALLOCATION_READ, $server)) {
|
||||
if (!$this->getUser()->can(Permission::ACTION_ALLOCATION_READ, $server)) {
|
||||
$primary = clone $server->allocation;
|
||||
$primary->notes = null;
|
||||
|
||||
|
@ -106,14 +99,13 @@ class ServerTransformer extends BaseClientTransformer
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeVariables(Server $server)
|
||||
{
|
||||
if (! $this->getUser()->can(Permission::ACTION_STARTUP_READ, $server)) {
|
||||
if (!$this->getUser()->can(Permission::ACTION_STARTUP_READ, $server)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
@ -127,8 +119,8 @@ class ServerTransformer extends BaseClientTransformer
|
|||
/**
|
||||
* Returns the egg associated with this server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return \League\Fractal\Resource\Item
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeEgg(Server $server)
|
||||
|
@ -139,14 +131,13 @@ class ServerTransformer extends BaseClientTransformer
|
|||
/**
|
||||
* Returns the subusers associated with this server.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeSubusers(Server $server)
|
||||
{
|
||||
if (! $this->getUser()->can(Permission::ACTION_USER_READ, $server)) {
|
||||
if (!$this->getUser()->can(Permission::ACTION_USER_READ, $server)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,6 @@ use Illuminate\Support\Arr;
|
|||
|
||||
class StatsTransformer extends BaseClientTransformer
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
return 'stats';
|
||||
|
@ -18,7 +15,6 @@ class StatsTransformer extends BaseClientTransformer
|
|||
* Transform stats from the daemon into a result set that can be used in
|
||||
* the client API.
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function transform(array $data)
|
||||
|
|
|
@ -8,8 +8,6 @@ class SubuserTransformer extends BaseClientTransformer
|
|||
{
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
|
@ -19,8 +17,8 @@ class SubuserTransformer extends BaseClientTransformer
|
|||
/**
|
||||
* Transforms a subuser into a model that can be shown to a front-end user.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Subuser $model
|
||||
* @return array|void
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function transform(Subuser $model)
|
||||
|
|
|
@ -17,7 +17,6 @@ class TaskTransformer extends BaseClientTransformer
|
|||
/**
|
||||
* Transforms a schedule's task into a client viewable format.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Task $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Task $model)
|
||||
|
|
|
@ -9,8 +9,6 @@ class UserTransformer extends BaseClientTransformer
|
|||
{
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
|
@ -21,7 +19,6 @@ class UserTransformer extends BaseClientTransformer
|
|||
* Transforms a User model into a representation that can be shown to regular
|
||||
* users of the API.
|
||||
*
|
||||
* @param \Pterodactyl\Models\User $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(User $model)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue