2019-07-28 03:23:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Transformers\Daemon;
|
|
|
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
use Illuminate\Support\Arr;
|
|
|
|
|
|
|
|
class FileObjectTransformer extends BaseDaemonTransformer
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* An array of files we allow editing in the Panel.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
private $editable = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transform a file object response from the daemon into a standardized response.
|
|
|
|
*
|
|
|
|
* @param array $item
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function transform(array $item)
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'name' => Arr::get($item, 'name'),
|
|
|
|
'mode' => Arr::get($item, 'mode'),
|
2020-11-29 21:46:35 +00:00
|
|
|
'mode_bits' => Arr::get($item, 'mode_bits'),
|
2019-07-28 03:23:51 +00:00
|
|
|
'size' => Arr::get($item, 'size'),
|
|
|
|
'is_file' => Arr::get($item, 'file', true),
|
|
|
|
'is_symlink' => Arr::get($item, 'symlink', false),
|
2020-08-30 17:25:48 +00:00
|
|
|
'mimetype' => Arr::get($item, 'mime', 'application/octet-stream'),
|
2019-08-06 05:22:31 +00:00
|
|
|
'created_at' => Carbon::parse(Arr::get($item, 'created', ''))->toIso8601String(),
|
|
|
|
'modified_at' => Carbon::parse(Arr::get($item, 'modified', ''))->toIso8601String(),
|
2019-07-28 03:23:51 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getResourceName(): string
|
|
|
|
{
|
|
|
|
return 'file_object';
|
|
|
|
}
|
|
|
|
}
|