Basic backend support to at least store a backup model in the DB
This commit is contained in:
parent
6d426e45d9
commit
d27f0c6f2a
10 changed files with 138 additions and 18 deletions
|
@ -3,6 +3,7 @@
|
|||
namespace Pterodactyl\Http\Controllers\Api\Client\Servers;
|
||||
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Services\Backups\InitiateBackupService;
|
||||
use Pterodactyl\Transformers\Api\Client\BackupTransformer;
|
||||
use Pterodactyl\Http\Controllers\Api\Client\ClientApiController;
|
||||
use Pterodactyl\Http\Requests\Api\Client\Servers\Backups\GetBackupsRequest;
|
||||
|
@ -10,9 +11,21 @@ use Pterodactyl\Http\Requests\Api\Client\Servers\Backups\StoreBackupRequest;
|
|||
|
||||
class BackupController extends ClientApiController
|
||||
{
|
||||
public function __construct()
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Backups\InitiateBackupService
|
||||
*/
|
||||
private $initiateBackupService;
|
||||
|
||||
/**
|
||||
* BackupController constructor.
|
||||
*
|
||||
* @param \Pterodactyl\Services\Backups\InitiateBackupService $initiateBackupService
|
||||
*/
|
||||
public function __construct(InitiateBackupService $initiateBackupService)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->initiateBackupService = $initiateBackupService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,9 +48,19 @@ class BackupController extends ClientApiController
|
|||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\StoreBackupRequest $request
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return array
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function store(StoreBackupRequest $request, Server $server)
|
||||
{
|
||||
$backup = $this->initiateBackupService
|
||||
->setIgnoredFiles($request->input('ignored'))
|
||||
->handle($server, $request->input('name'));
|
||||
|
||||
return $this->fractal->item($backup)
|
||||
->transformWith($this->getTransformer(BackupTransformer::class))
|
||||
->toArray();
|
||||
}
|
||||
|
||||
public function view()
|
||||
|
|
|
@ -21,7 +21,7 @@ class StoreBackupRequest extends ClientApiRequest
|
|||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'nullable|string|max:255',
|
||||
'name' => 'nullable|string|max:255|regex:/^[w\][\w\s_.-]*[\w]$/',
|
||||
'ignore' => 'nullable|string',
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue