2019-07-27 20:23:51 -07:00
|
|
|
<?php
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2022-05-22 16:23:22 -04:00
|
|
|
namespace Pterodactyl\Transformers\Api\Client;
|
2019-07-27 20:23:51 -07:00
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
use Illuminate\Support\Facades\Date;
|
2019-07-27 20:23:51 -07:00
|
|
|
|
2022-05-22 16:23:22 -04:00
|
|
|
class FileObjectTransformer extends BaseClientTransformer
|
2019-07-27 20:23:51 -07:00
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Transform a file object response from the daemon into a standardized response.
|
2026-10-05 18:10:18 -04:00
|
|
|
*
|
|
|
|
|
* @param DaemonFileObject $item
|
|
|
|
|
* @return ApiPayload
|
2019-07-27 20:23:51 -07:00
|
|
|
*/
|
2022-10-14 10:59:20 -06:00
|
|
|
public function transform(array $item): array
|
2019-07-27 20:23:51 -07:00
|
|
|
{
|
|
|
|
|
return [
|
2026-10-05 18:10:18 -04:00
|
|
|
'name' => $item['name'] ?? null,
|
|
|
|
|
'mode' => $item['mode'] ?? null,
|
|
|
|
|
'mode_bits' => $item['mode_bits'] ?? null,
|
|
|
|
|
'size' => $item['size'] ?? null,
|
|
|
|
|
'is_file' => $item['file'] ?? true,
|
|
|
|
|
'is_symlink' => $item['symlink'] ?? false,
|
|
|
|
|
'mimetype' => $item['mime'] ?? 'application/octet-stream',
|
|
|
|
|
'created_at' => Date::parse($item['created'] ?? '')->toAtomString(),
|
|
|
|
|
'modified_at' => Date::parse($item['modified'] ?? '')->toAtomString(),
|
2019-07-27 20:23:51 -07:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getResourceName(): string
|
|
|
|
|
{
|
|
|
|
|
return 'file_object';
|
|
|
|
|
}
|
|
|
|
|
}
|