misc_pterodactyl-panel/app/Transformers/Api/Application/ServerVariableTransformer.php

48 lines
1.2 KiB
PHP
Raw Normal View History

<?php
namespace Pterodactyl\Transformers\Api\Application;
use Pterodactyl\Models\EggVariable;
use Pterodactyl\Models\ServerVariable;
use Pterodactyl\Services\Acl\Api\AdminAcl;
use Pterodactyl\Transformers\Api\Transformer;
class ServerVariableTransformer extends Transformer
{
/**
* List of resources that can be included.
*
* @var array
*/
protected $availableIncludes = ['parent'];
/**
* Return the resource name for the JSONAPI output.
*/
public function getResourceName(): string
{
return ServerVariable::RESOURCE_NAME;
}
public function transform(EggVariable $model): array
{
return $model->toArray();
}
/**
* Return the parent service variable data.
*
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
*/
public function includeParent(EggVariable $variable)
{
2021-01-23 20:33:34 +00:00
if (!$this->authorize(AdminAcl::RESOURCE_EGGS)) {
return $this->null();
}
// TODO: confirm this code?
// @phpstan-ignore-next-line This might actually be wrong, not sure?
return $this->item($variable->variable, new EggVariableTransformer());
}
}