Merge branch 'develop' into feature/react-admin

This commit is contained in:
Matthew Penner 2021-01-23 14:39:23 -07:00
commit 8feb87de7c
532 changed files with 4262 additions and 5622 deletions

View file

@ -16,8 +16,6 @@ class NodeTransformer extends BaseTransformer
/**
* Return the resource name for the JSONAPI output.
*
* @return string
*/
public function getResourceName(): string
{
@ -27,10 +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 $model
*
* @return array
*/
public function transform(Node $model): array
{
@ -58,66 +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
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
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
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
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
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
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'
);
}
}