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