-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugin.php
More file actions
81 lines (67 loc) · 3.16 KB
/
Copy pathPlugin.php
File metadata and controls
81 lines (67 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
namespace App\Vito\Plugins\Cp6\VitoDeployDatabaseExport;
use App\Plugins\AbstractPlugin;
use App\Plugins\RegisterServerFeature;
use App\Plugins\RegisterServerFeatureAction;
use App\Plugins\RegisterViews;
use App\Vito\Plugins\Cp6\VitoDeployDatabaseExport\Database\SchemaManager;
use App\Vito\Plugins\Cp6\VitoDeployDatabaseExport\Http\Controllers\DatabaseExportController;
use App\Vito\Plugins\Cp6\VitoDeployDatabaseExport\ServerFeatures\OpenExporter;
use Illuminate\Support\Facades\Route;
class Plugin extends AbstractPlugin
{
protected string $name = 'Database Exporter';
protected string $description = 'Create and securely download queued database exports from VitoDeploy.';
public function boot(): void
{
$defaults = require __DIR__.'/config/database-export.php';
config(['database-export' => array_replace_recursive($defaults, config('database-export', []))]);
RegisterViews::make('vito-database-export')
->path(__DIR__.'/resources/views')
->register();
$this->registerRoutes();
$this->registerServerFeature();
}
public function install(): void
{
app(SchemaManager::class)->ensureInstalled();
}
public function enable(): void
{
app(SchemaManager::class)->ensureInstalled();
}
public function uninstall(): void
{
app(SchemaManager::class)->uninstall();
}
private function registerRoutes(): void
{
Route::middleware(['web', 'auth', 'has-project'])
->prefix('database-exporter')
->name('database-exporter.')
->group(function (): void {
Route::get('/assets/exporter.css', [DatabaseExportController::class, 'styles'])->name('styles');
Route::get('/', [DatabaseExportController::class, 'index'])->name('index');
Route::post('/runs/preview', [DatabaseExportController::class, 'preview'])->name('runs.preview');
Route::post('/runs/{run}/start', [DatabaseExportController::class, 'start'])->name('runs.start');
Route::get('/runs/{run}/download', [DatabaseExportController::class, 'download'])->name('runs.download');
Route::get('/runs/{run}', [DatabaseExportController::class, 'show'])->name('runs.show');
Route::post('/runs/{run}/retry', [DatabaseExportController::class, 'retry'])->name('runs.retry');
Route::post('/runs/{run}/cancel', [DatabaseExportController::class, 'cancel'])->name('runs.cancel');
Route::delete('/runs/{run}', [DatabaseExportController::class, 'destroy'])->name('runs.destroy');
});
Route::getRoutes()->refreshNameLookups();
Route::getRoutes()->refreshActionLookups();
}
private function registerServerFeature(): void
{
RegisterServerFeature::make('database-exporter')
->label('Database Exporter')
->description('Create a compressed SQL export and download it securely')
->register();
RegisterServerFeatureAction::make('database-exporter', 'open')
->label('Open Exporter')
->handler(OpenExporter::class)
->register();
}
}