misc_pterodactyl-panel/app/Transformers/Api/Application/ServerVariableTransformer.php
2021-09-15 21:22:15 -06:00

45 lines
1.1 KiB
PHP

<?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)
{
if (!$this->authorize(AdminAcl::RESOURCE_EGGS)) {
return $this->null();
}
return $this->item($variable->variable, new EggVariableTransformer());
}
}