Use a standardized transformer base; replace all client transformers to call that base

This commit is contained in:
Dane Everitt 2021-08-07 13:06:45 -07:00
parent 2203a4d87e
commit cf500a1a54
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
25 changed files with 255 additions and 379 deletions

View file

@ -3,28 +3,19 @@
namespace Pterodactyl\Transformers\Api\Client;
use Pterodactyl\Models\Subuser;
use Pterodactyl\Transformers\Api\Transformer;
class SubuserTransformer extends BaseClientTransformer
class SubuserTransformer extends Transformer
{
/**
* Return the resource name for the JSONAPI output.
*/
public function getResourceName(): string
{
return Subuser::RESOURCE_NAME;
}
/**
* Transforms a subuser into a model that can be shown to a front-end user.
*
* @return array|void
*
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
*/
public function transform(Subuser $model)
public function transform(Subuser $model): array
{
return array_merge(
$this->makeTransformer(UserTransformer::class)->transform($model->user),
(new UserTransformer())->transform($model->user),
['permissions' => $model->permissions]
);
}