misc_pterodactyl-panel/app/Transformers/Api/Client/FileObjectTransformer.php

34 lines
1 KiB
PHP
Raw Normal View History

2019-07-28 03:23:51 +00:00
<?php
2022-05-22 20:23:22 +00:00
namespace Pterodactyl\Transformers\Api\Client;
2019-07-28 03:23:51 +00:00
use Carbon\Carbon;
use Illuminate\Support\Arr;
2022-12-15 00:05:46 +00:00
use Pterodactyl\Transformers\Api\Transformer;
2019-07-28 03:23:51 +00:00
2022-12-15 00:05:46 +00:00
class FileObjectTransformer extends Transformer
2019-07-28 03:23:51 +00:00
{
2022-12-15 00:05:46 +00:00
public function getResourceName(): string
{
return 'file_object';
}
2019-07-28 03:23:51 +00:00
/**
* Transform a file object response from the daemon into a standardized response.
*/
2022-12-15 00:05:46 +00:00
public function transform(array $model): array
2019-07-28 03:23:51 +00:00
{
return [
2022-12-15 00:05:46 +00:00
'name' => Arr::get($model, 'name'),
'mode' => Arr::get($model, 'mode'),
'mode_bits' => Arr::get($model, 'mode_bits'),
'size' => Arr::get($model, 'size'),
'is_file' => Arr::get($model, 'file', true),
'is_symlink' => Arr::get($model, 'symlink', false),
'mimetype' => Arr::get($model, 'mime', 'application/octet-stream'),
'created_at' => Carbon::parse(Arr::get($model, 'created', ''))->toAtomString(),
'modified_at' => Carbon::parse(Arr::get($model, 'modified', ''))->toAtomString(),
2019-07-28 03:23:51 +00:00
];
}
}