misc_pterodactyl-panel/app/Transformers/Api/Client/BackupTransformer.php
Dane Everitt e3178ba6f0
backend: support is_successful state for backups rather than deleting it when failing
This allows the UI to correctly show failed backups to the user and require them to manually delete those backups, rather than them mysteriously disappearing.

We can also hook into this later to send a notification to the user when the backup fails.
2020-08-20 21:07:53 -07:00

34 lines
897 B
PHP

<?php
namespace Pterodactyl\Transformers\Api\Client;
use Pterodactyl\Models\Backup;
class BackupTransformer extends BaseClientTransformer
{
/**
* @return string
*/
public function getResourceName(): string
{
return Backup::RESOURCE_NAME;
}
/**
* @param \Pterodactyl\Models\Backup $backup
* @return array
*/
public function transform(Backup $backup)
{
return [
'uuid' => $backup->uuid,
'is_successful' => $backup->is_successful,
'name' => $backup->name,
'ignored_files' => $backup->ignored_files,
'sha256_hash' => $backup->sha256_hash,
'bytes' => $backup->bytes,
'created_at' => $backup->created_at->toIso8601String(),
'completed_at' => $backup->completed_at ? $backup->completed_at->toIso8601String() : null,
];
}
}