Make server listing and single server view API endpoints work

This commit is contained in:
Dane Everitt 2018-01-19 21:47:06 -06:00
parent 74bdbea6a4
commit a497a3d153
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
39 changed files with 367 additions and 176 deletions

View file

@ -0,0 +1,44 @@
<?php
namespace Pterodactyl\Transformers\Api\Application;
use Pterodactyl\Models\ServerVariable;
use Pterodactyl\Services\Acl\Api\AdminAcl;
class ServerVariableTransformer extends BaseTransformer
{
/**
* List of resources that can be included.
*
* @var array
*/
protected $availableIncludes = ['parent'];
/**
* Return a generic transformed server variable array.
*
* @param \Pterodactyl\Models\ServerVariable $variable
* @return array
*/
public function transform(ServerVariable $variable)
{
return $variable->toArray();
}
/**
* Return the parent service variable data.
*
* @param \Pterodactyl\Models\ServerVariable $variable
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
*/
public function includeParent(ServerVariable $variable)
{
if (! $this->authorize(AdminAcl::RESOURCE_EGGS)) {
return $this->null();
}
$variable->loadMissing('variable');
return $this->item($variable->getRelation('variable'), $this->makeTransformer(EggVariableTransformer::class), 'variable');
}
}